You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2016/09/01 14:36:41 UTC

[21/22] lucenenet git commit: Fixed some minor code differences in Analysis.Compound.Hyphenation

Fixed some minor code differences in Analysis.Compound.Hyphenation


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

Branch: refs/heads/analysis-work
Commit: 8a05b1682b9d1405ed71d42e75d06a296736641d
Parents: 3664f1d
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Sat Aug 27 01:57:32 2016 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Sat Aug 27 02:20:14 2016 +0700

----------------------------------------------------------------------
 .../Analysis/Compound/hyphenation/HyphenationTree.cs     | 11 ++++++-----
 .../Analysis/Compound/hyphenation/PatternParser.cs       | 10 ++++------
 2 files changed, 10 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8a05b168/src/Lucene.Net.Analysis.Common/Analysis/Compound/hyphenation/HyphenationTree.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Compound/hyphenation/HyphenationTree.cs b/src/Lucene.Net.Analysis.Common/Analysis/Compound/hyphenation/HyphenationTree.cs
index 33bc310..287f6f3 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Compound/hyphenation/HyphenationTree.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Compound/hyphenation/HyphenationTree.cs
@@ -1,4 +1,5 @@
-\ufeffusing System;
+\ufeffusing Lucene.Net.Support;
+using System;
 using System.Collections.Generic;
 using System.IO;
 using System.Text;
@@ -40,7 +41,7 @@ namespace Lucene.Net.Analysis.Compound.Hyphenation
         /// <summary>
         /// This map stores hyphenation exceptions
         /// </summary>
-        protected internal Dictionary<string, List<object>> stoplist;
+        protected internal IDictionary<string, IList<object>> stoplist;
 
         /// <summary>
         /// This map stores the character classes
@@ -55,7 +56,7 @@ namespace Lucene.Net.Analysis.Compound.Hyphenation
 
         public HyphenationTree()
         {
-            stoplist = new Dictionary<string, List<object>>(23); // usually a small table
+            stoplist = new HashMap<string, IList<object>>(23); // usually a small table
             classmap = new TernaryTree();
             vspace = new ByteVector();
             vspace.Alloc(1); // this reserves index 0, which we don't use
@@ -234,7 +235,7 @@ namespace Lucene.Net.Analysis.Compound.Hyphenation
             sbyte v = vspace[k++];
             while (v != 0)
             {
-                char c = (char)(((int)((uint)v >> 4)) - 1);
+                char c = (char)((((int)((uint)v >> 4))) - 1);
                 buf.Append(c);
                 c = (char)(v & 0x0f);
                 if (c == 0)
@@ -453,7 +454,7 @@ namespace Lucene.Net.Analysis.Compound.Hyphenation
             {
                 // assume only simple hyphens (Hyphen.pre="-", Hyphen.post = Hyphen.no =
                 // null)
-                List<object> hw = stoplist[sw];
+                IList<object> hw = stoplist[sw];
                 int j = 0;
                 for (i = 0; i < hw.Count; i++)
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8a05b168/src/Lucene.Net.Analysis.Common/Analysis/Compound/hyphenation/PatternParser.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Compound/hyphenation/PatternParser.cs b/src/Lucene.Net.Analysis.Common/Analysis/Compound/hyphenation/PatternParser.cs
index e94e8cf..33e07dd 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Compound/hyphenation/PatternParser.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Compound/hyphenation/PatternParser.cs
@@ -237,7 +237,7 @@ namespace Lucene.Net.Analysis.Compound.Hyphenation
                     break;
                 }
             }
-            token.Append(chars.ToString(0, i));
+            token.Append(chars.ToString(0, i - 0));
             // chars.delete(0,i);
             for (int countr = i; countr < chars.Length; countr++)
             {
@@ -250,7 +250,7 @@ namespace Lucene.Net.Analysis.Compound.Hyphenation
                 token.Length = 0;
                 return word;
             }
-            token.Append(chars);
+            token.Append(chars.ToString());
             return null;
         }
 
@@ -360,7 +360,7 @@ namespace Lucene.Net.Analysis.Compound.Hyphenation
             public override object GetEntity(Uri absoluteUri, string role, Type ofObjectToReturn)
             {
                 string dtdFilename = "hyphenation.dtd";
-                if (dtdFilename.Equals(absoluteUri.Segments.LastOrDefault()))
+                if (dtdFilename.Equals(absoluteUri.Segments.LastOrDefault(), StringComparison.OrdinalIgnoreCase))
                 {
                     var qualifedDtdFilename = string.Concat(GetType().Namespace, ".", dtdFilename);
                     return GetType().Assembly.GetManifestResourceStream(qualifedDtdFilename);
@@ -415,7 +415,6 @@ namespace Lucene.Net.Analysis.Compound.Hyphenation
         ///      java.lang.String, java.lang.String) </seealso>
         public void EndElement(string uri, string local, string raw)
         {
-
             if (token.Length > 0)
             {
                 string word = token.ToString();
@@ -449,7 +448,6 @@ namespace Lucene.Net.Analysis.Compound.Hyphenation
             {
                 currElement = 0;
             }
-
         }
 
         /// <seealso cref= org.xml.sax.ContentHandler#characters(char[], int, int) </seealso>
@@ -458,7 +456,7 @@ namespace Lucene.Net.Analysis.Compound.Hyphenation
             StringBuilder chars = new StringBuilder(length);
             chars.Append(ch, start, length);
             string word = ReadToken(chars);
-            while (!string.IsNullOrEmpty(word))
+            while (word != null)
             {
                 // System.out.println("\"" + word + "\"");
                 switch (currElement)