<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Метод SIFT3, добавить поддержку русских символов]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=16233&amp;type=atom" />
	<updated>2021-04-04T14:35:21Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=16233</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Метод SIFT3, добавить поддержку русских символов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147163#p147163" />
			<content type="html"><![CDATA[<p>Если работает, то и так нормально, разбираться не особо интересно. Хотите лучше понять — читайте про алгоритм Левенштейна.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-04-04T14:35:21Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147163#p147163</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Метод SIFT3, добавить поддержку русских символов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147155#p147155" />
			<content type="html"><![CDATA[<p>Мне непонятно значение 0.2 в первом ифе, что оно значит.. фиг поймешь.<br />Вроде работает как нужно.. Но как это можно нормально записать?</p><div class="codebox"><pre><code>stringDiff(string1, string2, ignoreRegister := 1, maxOffset = 5)
{
	StringCaseSense, Locale

	if (ignoreRegister &amp;&amp; string1 = string2)
		return (string1 == string2 ? 0 : 0.2 / StrLen(string1))
	if (string1 = &quot;&quot; || string2 = &quot;&quot;)
		return (string1 = string2 ? 0 : 1)

	StringSplit, n, string1
	StringSplit, m, string2

	ni := 1, mi := 1, lcs := 0
	While((ni &lt;= n0 &amp;&amp; mi &lt;= m0))
	{
		if (n%ni% == m%mi%)
			EnvAdd, lcs, 1
		else if (ignoreRegister &amp;&amp; n%ni% = m%mi%)
			EnvAdd, lcs, 0.8
		else
		{
			Loop, %maxOffset%	
			{
				oi := ni + A_Index, pi := mi + A_Index
				if (n%oi% = m%mi% &amp;&amp; oi &lt;= n0)
				{
					ni := oi, lcs += (n%oi% == m%mi% ? 1 : (ignoreRegister ? 0.8 : 0))
					Break
				}
				if ((n%ni% = m%pi% &amp;&amp; pi &lt;= m0))
				{
					mi := pi, lcs += (n%ni% == m%pi% ? 1 : (ignoreRegister ? 0.8 : 0))
					Break
				}
			}
		}
		EnvAdd, ni, 1
		EnvAdd, mi, 1
	}
	return ((n0 + m0)/2 - lcs) / (n0 &gt; m0 ? n0 : m0)
}

strings := [[&quot;AHK&quot;, &quot;AHK&quot;], [&quot;AHK&quot;, &quot;AhK&quot;], [&quot;Тест&quot;, &quot;Тест&quot;], [&quot;Тест&quot;, &quot;ТЕСТ&quot;], [&quot;Тест&quot;, &quot;ТеСт&quot;]]

out := &quot;&quot;
loop, 2
{
	ingnoreRegister := A_Index - 1
	out .= (A_Index == 2 ? &quot;`n&quot; : &quot;&quot;) &quot;Ingore register: &quot; ingnoreRegister &quot;`n&quot;
	
	for k, v in strings
	{
		out .= v[1] &quot; - &quot; v[2] &quot;`t&quot; stringDiff(v[1], v[2], ingnoreRegister) &quot;`n&quot;
	}
}

msgbox, % out</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2021-04-04T05:07:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147155#p147155</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Метод SIFT3, добавить поддержку русских символов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147154#p147154" />
			<content type="html"><![CDATA[<p>Попробуйте ввести дополнительный параметр, который будет регулировать, что будет применяться, == или =.</p>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-04-04T04:28:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147154#p147154</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Метод SIFT3, добавить поддержку русских символов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147153#p147153" />
			<content type="html"><![CDATA[<p>Да, это сработало, а как теперь можно сделать по умному отключение независимость регистра?</p>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2021-04-04T03:34:31Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147153#p147153</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Метод SIFT3, добавить поддержку русских символов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147152#p147152" />
			<content type="html"><![CDATA[<p>Добавьте первой строчкой<br /></p><div class="codebox"><pre><code>StringCaseSense, Locale</code></pre></div>]]></content>
			<author>
				<name><![CDATA[teadrinker]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=24515</uri>
			</author>
			<updated>2021-04-04T03:21:41Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147152#p147152</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Метод SIFT3, добавить поддержку русских символов]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=147149#p147149" />
			<content type="html"><![CDATA[<p>Мне нужно узнать разницу между двумя строками, я взял код отсюда: <a href="https://autohotkey.com/board/topic/54987-sift3-super-fast-and-accurate-string-distance-algorithm/">https://autohotkey.com/board/topic/5498 … algorithm/</a>.<br />Но я заметил, что есть разница между русскими и англ буквами, точнее разница между регистром.</p><div class="codebox"><pre><code>stringDiff(string1, string2, maxOffset = 5)
{
	if (string1 = string2)
		return (string1 == string2 ? 0/1 : 0.2/StrLen(string1))
	if (string1 = &quot;&quot; OR string2 = &quot;&quot;)
		return (string1 = string2 ? 0/1 : 1/1)

	StringSplit, n, string1
	StringSplit, m, string2

	ni := 1, mi := 1, lcs := 0
	While((ni &lt;= n0) AND (mi &lt;= m0)) 
	{
		if (n%ni% == m%mi%)
			EnvAdd, lcs, 1
		else if (n%ni% = m%mi%)
			EnvAdd, lcs, 0.8
		else
		{
			Loop, %maxOffset%	
			{
				oi := ni + A_Index, pi := mi + A_Index
				if ((n%oi% = m%mi%) AND (oi &lt;= n0))
				{
					ni := oi, lcs += (n%oi% == m%mi% ? 1 : 0.8)
					Break
				}
				if ((n%ni% = m%pi%) AND (pi &lt;= m0))
				{
					mi := pi, lcs += (n%ni% == m%pi% ? 1 : 0.8)
					Break
				}
			}
		}
		EnvAdd, ni, 1
		EnvAdd, mi, 1
	}
	return ((n0 + m0)/2 - lcs) / (n0 &gt; m0 ? n0 : m0)
}

msgbox, % stringDiff(&quot;AHK&quot;, &quot;AhK&quot;)
msgbox, % stringDiff(&quot;АХК&quot;, &quot;АхК&quot;)</code></pre></div><p>Что можно придумать? Я так понимаю дело в &quot;=&quot; и &quot;==&quot;, оно работает только на англ буквы (как &quot;i&quot; в регулярных выражениях).</p><p>В идеале иметь возможность включать/выключать поддержку регистра (то есть, чтобы буквы в разном регистре считались за разные, а не за 0.8).</p>]]></content>
			<author>
				<name><![CDATA[Phoenixxx_Czar]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=34426</uri>
			</author>
			<updated>2021-04-04T01:35:30Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=147149#p147149</id>
		</entry>
</feed>
