You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by ni...@apache.org on 2017/01/31 17:56:15 UTC

[42/50] [abbrv] lucenenet git commit: Lucene.Net.Suggest.Spell.SpellChecker refactor: SpellIndex (setter only) > SetSpellIndex(). Lucene.Net.Suggest.Suggest.Jaspell.JaspellTernarySearchTrie refactor: Added getters to MatchAlmostDiff and NumReturnValues p

Lucene.Net.Suggest.Spell.SpellChecker refactor: SpellIndex (setter only) > SetSpellIndex(). Lucene.Net.Suggest.Suggest.Jaspell.JaspellTernarySearchTrie refactor: Added getters to MatchAlmostDiff and NumReturnValues properties per MSDN guidelines.


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

Branch: refs/heads/api-work
Commit: ae5157872cdd9ca97b2c1d755161d6ce3e47cca2
Parents: e9db285
Author: Shad Storhaug <sh...@shadstorhaug.com>
Authored: Tue Jan 31 19:50:53 2017 +0700
Committer: Shad Storhaug <sh...@shadstorhaug.com>
Committed: Tue Jan 31 19:50:53 2017 +0700

----------------------------------------------------------------------
 src/Lucene.Net.Suggest/Spell/SpellChecker.cs    | 25 +++++++++-----------
 .../Suggest/Jaspell/JaspellTernarySearchTrie.cs | 10 +++++++-
 .../Spell/TestSpellChecker.cs                   |  4 ++--
 3 files changed, 22 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ae515787/src/Lucene.Net.Suggest/Spell/SpellChecker.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Suggest/Spell/SpellChecker.cs b/src/Lucene.Net.Suggest/Spell/SpellChecker.cs
index 23e916a..76b02e6 100644
--- a/src/Lucene.Net.Suggest/Spell/SpellChecker.cs
+++ b/src/Lucene.Net.Suggest/Spell/SpellChecker.cs
@@ -128,7 +128,7 @@ namespace Lucene.Net.Search.Spell
         /// <exception cref="System.IO.IOException"> if there is a problem opening the index </exception>
         public SpellChecker(Directory spellIndex, IStringDistance sd, IComparer<SuggestWord> comparer)
         {
-            SpellIndex = spellIndex;
+            SetSpellIndex(spellIndex);
             StringDistance = sd;
             this.comparer = comparer;
         }
@@ -141,25 +141,22 @@ namespace Lucene.Net.Search.Spell
         /// <exception cref="AlreadyClosedException"> if the Spellchecker is already closed </exception>
         /// <exception cref="System.IO.IOException"> if spellchecker can not open the directory </exception>
         // TODO: we should make this final as it is called in the constructor
-        public virtual Directory SpellIndex
+        public virtual void SetSpellIndex(Directory spellIndexDir)
         {
-            set
+            // this could be the same directory as the current spellIndex
+            // modifications to the directory should be synchronized 
+            lock (modifyCurrentIndexLock)
             {
-                // this could be the same directory as the current spellIndex
-                // modifications to the directory should be synchronized 
-                lock (modifyCurrentIndexLock)
+                EnsureOpen();
+                if (!DirectoryReader.IndexExists(spellIndexDir))
                 {
-                    EnsureOpen();
-                    if (!DirectoryReader.IndexExists(value))
-                    {
 #pragma warning disable 612, 618
-                        using (var writer = new IndexWriter(value, new IndexWriterConfig(LuceneVersion.LUCENE_CURRENT, null)))
-                        {
-                        }
-#pragma warning restore 612, 618
+                    using (var writer = new IndexWriter(spellIndexDir, new IndexWriterConfig(LuceneVersion.LUCENE_CURRENT, null)))
+                    {
                     }
-                    SwapSearcher(value);
+#pragma warning restore 612, 618
                 }
+                SwapSearcher(spellIndexDir);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ae515787/src/Lucene.Net.Suggest/Suggest/Jaspell/JaspellTernarySearchTrie.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Suggest/Suggest/Jaspell/JaspellTernarySearchTrie.cs b/src/Lucene.Net.Suggest/Suggest/Jaspell/JaspellTernarySearchTrie.cs
index 722147c..4d4568e 100644
--- a/src/Lucene.Net.Suggest/Suggest/Jaspell/JaspellTernarySearchTrie.cs
+++ b/src/Lucene.Net.Suggest/Suggest/Jaspell/JaspellTernarySearchTrie.cs
@@ -911,6 +911,10 @@ namespace Lucene.Net.Search.Suggest.Jaspell
         ///          word. </param>
         public virtual int MatchAlmostDiff
         {
+            get // LUCENENET NOTE: Added property get per MSDN guidelines
+            {
+                return matchAlmostDiff;
+            }
             set
             {
                 if (value < 0)
@@ -942,6 +946,10 @@ namespace Lucene.Net.Search.Suggest.Jaspell
         ///          methods above. </param>
         public virtual int NumReturnValues
         {
+            get // LUCENENET NOTE: Added property get per MSDN guidelines
+            {
+                return defaultNumReturnValues;
+            }
             set
             {
                 defaultNumReturnValues = (value < 0) ? -1 : value;
@@ -962,7 +970,7 @@ namespace Lucene.Net.Search.Suggest.Jaspell
         /// <param name="numReturnValues">
         ///          The maximum number of values returned from this method. </param>
         /// <returns> A <see cref="IList{String}"/> with the results. </returns>
-        protected internal virtual IList<string> SortKeys(TSTNode startNode, int numReturnValues)
+        protected virtual IList<string> SortKeys(TSTNode startNode, int numReturnValues)
         {
             return SortKeysRecursion(startNode, ((numReturnValues < 0) ? -1 : numReturnValues), new List<string>());
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ae515787/src/Lucene.Net.Tests.Suggest/Spell/TestSpellChecker.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Suggest/Spell/TestSpellChecker.cs b/src/Lucene.Net.Tests.Suggest/Spell/TestSpellChecker.cs
index 594fbde..14884ca 100644
--- a/src/Lucene.Net.Tests.Suggest/Spell/TestSpellChecker.cs
+++ b/src/Lucene.Net.Tests.Suggest/Spell/TestSpellChecker.cs
@@ -447,7 +447,7 @@ namespace Lucene.Net.Search.Spell
 
                 try
                 {
-                    spellChecker.SpellIndex = (spellindex);
+                    spellChecker.SetSpellIndex(spellindex);
                     fail("spellchecker was already closed");
                 }
                 catch (AlreadyClosedException /*e*/)
@@ -492,7 +492,7 @@ namespace Lucene.Net.Search.Spell
                 {
                     Thread.Sleep(100);
                     // concurrently reset the spell index
-                    spellChecker.SpellIndex = (this.spellindex);
+                    spellChecker.SetSpellIndex(this.spellindex);
                     // for debug - prints the internal open searchers 
                     // showSearchersOpen();
                 }