Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CF790200C4F for ; Sat, 1 Apr 2017 17:02:54 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id CDE0B160B8D; Sat, 1 Apr 2017 15:02:54 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id F1E10160BA0 for ; Sat, 1 Apr 2017 17:02:53 +0200 (CEST) Received: (qmail 41565 invoked by uid 500); 1 Apr 2017 15:02:53 -0000 Mailing-List: contact commits-help@lucenenet.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@lucenenet.apache.org Delivered-To: mailing list commits@lucenenet.apache.org Received: (qmail 41421 invoked by uid 99); 1 Apr 2017 15:02:53 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Apr 2017 15:02:53 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D3A49DFF7C; Sat, 1 Apr 2017 15:02:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: nightowl888@apache.org To: commits@lucenenet.apache.org Date: Sat, 01 Apr 2017 15:02:53 -0000 Message-Id: <14de93ea433b4b1eb942e5103d1bab8e@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer 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 archived-at: Sat, 01 Apr 2017 15:02:55 -0000 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 Authored: Sat Apr 1 20:20:23 2017 +0700 Committer: Shad Storhaug 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; - } } + /// + /// If true, this will preserve + /// positions of the incoming tokens (ie, accumulate and + /// set position increments of the removed tokens). + /// Generally, true is best as it does not + /// lose information (positions of the original tokens) + /// during indexing. + /// + /// When set, when a token is stopped + /// (omitted), the position increment of the following + /// token is incremented. + /// + // 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(); IPositionIncrementAttribute posIncrAtt = stpf.GetAttribute(); 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); } }