How to read line
edon2005 opened this issue · comments
HI,
First of all thank you for library.
I just work on Swift version for library.
And can't understand line:
if ((prefixLength - maxEditDistance == candidateLen)
&& (((min = Math.Min(inputLen, suggestionLen) - prefixLength) > 1)
&& (input.Substring(inputLen + 1 - min) != suggestion.Substring(suggestionLen + 1 - min)))
|| ((min > 0) && (input[inputLen - min] != suggestion[suggestionLen - min])
&& ((input[inputLen - min - 1] != suggestion[suggestionLen - min])
|| (input[inputLen - min] != suggestion[suggestionLen - min - 1]))))
{
When will be changed min?
Only if prefixLength - maxEditDistance == candidateLen ?
Or if Math.Min(inputLen, suggestionLen) - prefixLength) > 1 ?
Thanks a lot!
min will be changed only, if prefixLength - maxEditDistance == candidateLen.
If this is the case, then min = Math.Min(inputLen, suggestionLen) - prefixLength
This is just a (probably unnecessary) micro optimization.
Otherwise you could rewrite it as follows:
int min = Math.Min(inputLen, suggestionLen) - prefixLength; //in line 480
...
if ((prefixLength - maxEditDistance == candidateLen)
&& ((min > 1)
&& (input.Substring(inputLen + 1 - min) != suggestion.Substring(suggestionLen + 1 - min)))
|| ((min > 0) && (input[inputLen - min] != suggestion[suggestionLen - min])
&& ((input[inputLen - min - 1] != suggestion[suggestionLen - min])
|| (input[inputLen - min] != suggestion[suggestionLen - min - 1]))))
{
Thank you very much.
Pozdrawiam,
Gienek.
Nie ma za co ;-)
Please let me know once your Swift library is ready (if it is Open Source).
I will happily link to it from my SymSpell repository.
Regards, Wolf
Sure :) when i finish it. I’ll send you a link.
one more question please. Line 894.
suggestionsSplit.Sort((x, y) => 2 * x.distance.CompareTo(y.distance) - x.count.CompareTo(y.count));
How this array should be sorted?
Suggestions are sorted by increasing edit distance, then by decreasing term frequency.
I intentionally did not use OrderBy and ThenBy from LINQ., in order to improve portability.
thanks again :)