lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [50/50] [abbrv] lucenenet git commit: Fixed bug in Hunspell with the word order validation due to use of CompareTo, which is using different sorting rules than Java.
Date Tue, 23 Aug 2016 23:18:43 GMT
Fixed bug in Hunspell with the word order validation due to use of CompareTo, which is using
different sorting rules than Java.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/4deebe8f
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/4deebe8f
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/4deebe8f

Branch: refs/heads/analysis-work
Commit: 4deebe8fe40bec9a0164839aa6e4bd0e04701ae9
Parents: 1995da2
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Tue Aug 23 18:32:54 2016 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Tue Aug 23 18:32:54 2016 +0700

----------------------------------------------------------------------
 .../Analysis/Hunspell/Dictionary.cs             | 24 ++++++++------------
 1 file changed, 10 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4deebe8f/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/Dictionary.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/Dictionary.cs b/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/Dictionary.cs
index f1b2467..8bab079 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/Dictionary.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Hunspell/Dictionary.cs
@@ -852,19 +852,15 @@ namespace Lucene.Net.Analysis.Hunspell
                     Array.Sort(wordForm);
                     entry = line2.Substring(0, flagSep - 0);
                 }
-
-                int cmp = currentEntry == null ? 1 : entry.CompareTo(currentEntry);
-                // LUCENENET TODO: For some reason the CompareTo method is working differently
in .NET
-                // than it does in Java when it comes to strings. This check seems to fail
on every dictionary.
-                // However, we must assume that most (if not all) dictionaries are sorted
correctly, so 
-                // in order to make it function at all, this validation check is being removed.
But 
-                // if the reason why it is failing can be determined, it probably should
be put back in.
-                //if (cmp < 0)
-                //{
-                //    throw new System.ArgumentException("out of order: " + entry + " <
" + currentEntry);
-                //}
-                //else
-                //{
+                // LUCENENET NOTE: CompareToOrdinal is an extension method that works similarly
to
+                // Java's String.compareTo method.
+                int cmp = currentEntry == null ? 1 : entry.CompareToOrdinal(currentEntry);
+                if (cmp < 0)
+                {
+                    throw new System.ArgumentException("out of order: " + entry + " <
" + currentEntry);
+                }
+                else
+                {
                     EncodeFlags(flagsScratch, wordForm);
                     int ord = flagLookup.Add(flagsScratch);
                     if (ord < 0)
@@ -886,7 +882,7 @@ namespace Lucene.Net.Analysis.Hunspell
                     }
                     currentOrds.Grow(currentOrds.Length + 1);
                     currentOrds.Ints[currentOrds.Length++] = ord;
-                //}
+                }
             }
 
             // finalize last entry


Mime
View raw message