lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [2/4] lucenenet git commit: Lucene.Net.Analysis.Common.Util.FilteringTokenFilter refactor: Changed setter of EnablePositionIncrements back to a method because there is no way to mark it obsolete on a property without also marking the getter obsolete, and
Date Sat, 01 Apr 2017 15:02:53 GMT
Lucene.Net.Analysis.Common.Util.FilteringTokenFilter refactor: Changed setter of EnablePositionIncrements
back to a method because there is no way to mark it obsolete on a property without also marking
the getter obsolete, and added documentation for the method.


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

Branch: refs/heads/api-work
Commit: 6d2dec49e6a9573f22669b9551ae2992bd5ff3ad
Parents: 4a687fd
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Sat Apr 1 20:20:23 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sat Apr 1 20:20:23 2017 +0700

----------------------------------------------------------------------
 .../Analysis/Core/StopFilterFactory.cs          |  4 ++-
 .../Analysis/Ga/IrishAnalyzer.cs                |  4 +--
 .../Analysis/Util/FilteringTokenFilter.cs       | 33 ++++++++++++++------
 .../Analysis/Core/TestStopFilter.cs             | 10 ++++--
 4 files changed, 36 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6d2dec49/src/Lucene.Net.Analysis.Common/Analysis/Core/StopFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Core/StopFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Core/StopFilterFactory.cs
index bb9ca76..0b5feb8 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Core/StopFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Core/StopFilterFactory.cs
@@ -146,7 +146,9 @@ namespace Lucene.Net.Analysis.Core
         public override TokenStream Create(TokenStream input)
         {
             StopFilter stopFilter = new StopFilter(m_luceneMatchVersion, input, stopWords);
-            stopFilter.EnablePositionIncrements = enablePositionIncrements;
+#pragma warning disable 612, 618
+            stopFilter.SetEnablePositionIncrements(enablePositionIncrements);
+#pragma warning restore 612, 618
             return stopFilter;
         }
     }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6d2dec49/src/Lucene.Net.Analysis.Common/Analysis/Ga/IrishAnalyzer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Ga/IrishAnalyzer.cs b/src/Lucene.Net.Analysis.Common/Analysis/Ga/IrishAnalyzer.cs
index 04bfcae..528d7f7 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Ga/IrishAnalyzer.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Ga/IrishAnalyzer.cs
@@ -141,10 +141,10 @@ namespace Lucene.Net.Analysis.Ga
             StopFilter s = new StopFilter(m_matchVersion, result, HYPHENATIONS);
 #pragma warning disable 612, 618
             if (!m_matchVersion.OnOrAfter(LuceneVersion.LUCENE_44))
-#pragma warning restore 612, 618
             {
-                s.EnablePositionIncrements = false;
+                s.SetEnablePositionIncrements(false);
             }
+#pragma warning restore 612, 618
             result = s;
             result = new ElisionFilter(result, DEFAULT_ARTICLES);
             result = new IrishLowerCaseFilter(result);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6d2dec49/src/Lucene.Net.Analysis.Common/Analysis/Util/FilteringTokenFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Util/FilteringTokenFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Util/FilteringTokenFilter.cs
index c829ac0..7e945b3 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Util/FilteringTokenFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Util/FilteringTokenFilter.cs
@@ -135,17 +135,32 @@ namespace Lucene.Net.Analysis.Util
             {
                 return enablePositionIncrements;
             }
-            // LUCENENET TODO:
-            // deprecated enablePositionIncrements=false is not supported anymore as of Lucene
4.4
-            // There doesn't appear to be a way to apply [Obsolete] on a property setter
only. The only way
-            // to make it show the obsolete warning is to change this back to a separate
Set method.
-            set
-            {
-                CheckPositionIncrement(m_version, value);
-                this.enablePositionIncrements = value;
-            }
         }
 
+        /// <summary>
+        /// If <c>true</c>, this <see cref="TokenFilter"/> will preserve
+        /// positions of the incoming tokens (ie, accumulate and
+        /// set position increments of the removed tokens).
+        /// Generally, <c>true</c> is best as it does not
+        /// lose information (positions of the original tokens)
+        /// during indexing.
+        /// 
+        /// <para/> When set, when a token is stopped
+        /// (omitted), the position increment of the following
+        /// token is incremented.
+        /// </summary>
+        // LUCENENET NOTE: Intentionally made this a setter method instead of a property
+        // because it is obsolete and there is no way to add the attibute to the setter but
not
+        // the getter of a property. Since it is obsolete, this method will eventually be
removed
+        // anyway.
+        [Obsolete("enablePositionIncrements=false is not supported anymore as of Lucene 4.4")]
+        public virtual void SetEnablePositionIncrements(bool enable)
+        {
+            CheckPositionIncrement(m_version, enable);
+            this.enablePositionIncrements = enable;
+        }
+        
+
         public override void End()
         {
             base.End();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6d2dec49/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestStopFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestStopFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestStopFilter.cs
index bf0f3fa..c820454 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestStopFilter.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Core/TestStopFilter.cs
@@ -112,7 +112,9 @@ namespace Lucene.Net.Analysis.Core
             CharArraySet stopSet1 = StopFilter.MakeStopSet(TEST_VERSION_CURRENT, stopWords1);
             reader = new StringReader(sb.ToString());
             StopFilter stpf0 = new StopFilter(TEST_VERSION_CURRENT, new MockTokenizer(reader,
MockTokenizer.WHITESPACE, false), stopSet0); // first part of the set
-            stpf0.EnablePositionIncrements = true;
+#pragma warning disable 612, 618
+            stpf0.SetEnablePositionIncrements(true);
+#pragma warning restore 612, 618
             StopFilter stpf01 = new StopFilter(TEST_VERSION_CURRENT, stpf0, stopSet1); //
two stop filters concatenated!
             DoTestStopPositons(stpf01, true);
         }
@@ -129,7 +131,9 @@ namespace Lucene.Net.Analysis.Core
         private void DoTestStopPositons(StopFilter stpf, bool enableIcrements)
         {
             log("---> test with enable-increments-" + (enableIcrements ? "enabled" : "disabled"));
-            stpf.EnablePositionIncrements = enableIcrements;
+#pragma warning disable 612, 618
+            stpf.SetEnablePositionIncrements(enableIcrements);
+#pragma warning restore 612, 618
             ICharTermAttribute termAtt = stpf.GetAttribute<ICharTermAttribute>();
             IPositionIncrementAttribute posIncrAtt = stpf.GetAttribute<IPositionIncrementAttribute>();
             stpf.Reset();
@@ -226,8 +230,8 @@ namespace Lucene.Net.Analysis.Core
                 TokenFilter filter = new MockSynonymFilter(outerInstance, tokenizer);
 #pragma warning disable 612, 618
                 StopFilter stopfilter = new StopFilter(Version.LUCENE_43, filter, StopAnalyzer.ENGLISH_STOP_WORDS_SET);
+                stopfilter.SetEnablePositionIncrements(false);
 #pragma warning restore 612, 618
-                stopfilter.EnablePositionIncrements = false;
                 return new TokenStreamComponents(tokenizer, stopfilter);
             }
         }


Mime
View raw message