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 2014/11/09 05:47:59 UTC
[3/4] lucenenet git commit: More Analysis porting fixes
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ASCIIFoldingFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ASCIIFoldingFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ASCIIFoldingFilter.cs
index 87574cc..f170ebf 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ASCIIFoldingFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ASCIIFoldingFilter.cs
@@ -1,6 +1,8 @@
using System.Diagnostics;
+using Lucene.Net.Analysis.Tokenattributes;
+using Lucene.Net.Util;
-namespace org.apache.lucene.analysis.miscellaneous
+namespace Lucene.Net.Analysis.Miscellaneous
{
/*
@@ -19,13 +21,7 @@ namespace org.apache.lucene.analysis.miscellaneous
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
- using PositionIncrementAttribute = org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
- using ArrayUtil = org.apache.lucene.util.ArrayUtil;
- using RamUsageEstimator = org.apache.lucene.util.RamUsageEstimator;
-
- /// <summary>
+ /// <summary>
/// This class converts alphabetic, numeric, and symbolic Unicode characters
/// which are not in the first 127 ASCII characters (the "Basic Latin" Unicode
/// block) into their ASCII equivalents, if one exists.
@@ -94,38 +90,30 @@ namespace org.apache.lucene.analysis.miscellaneous
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public boolean incrementToken() throws java.io.IOException
- public override bool incrementToken()
+ public override bool IncrementToken()
{
if (state != null)
{
Debug.Assert(preserveOriginal, "state should only be captured if preserveOriginal is true");
- restoreState(state);
+ RestoreState(state);
posIncAttr.PositionIncrement = 0;
state = null;
return true;
}
- if (input.incrementToken())
+ if (input.IncrementToken())
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final char[] buffer = termAtt.buffer();
- char[] buffer = termAtt.buffer();
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int length = termAtt.length();
- int length = termAtt.length();
+ char[] buffer = termAtt.Buffer();
+ int length = termAtt.Length;
// If no characters actually require rewriting then we
// just return token as-is:
for (int i = 0 ; i < length ; ++i)
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final char c = buffer[i];
char c = buffer[i];
if (c >= '\u0080')
{
- foldToASCII(buffer, length);
- termAtt.copyBuffer(output, 0, outputPos);
+ FoldToASCII(buffer, length);
+ termAtt.CopyBuffer(output, 0, outputPos);
break;
}
}
@@ -137,11 +125,9 @@ namespace org.apache.lucene.analysis.miscellaneous
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public void reset() throws java.io.IOException
- public override void reset()
+ public override void Reset()
{
- base.reset();
+ base.Reset();
state = null;
}
@@ -150,22 +136,20 @@ namespace org.apache.lucene.analysis.miscellaneous
/// accents are removed from accented characters. </summary>
/// <param name="input"> The string to fold </param>
/// <param name="length"> The number of characters in the input string </param>
- public void foldToASCII(char[] input, int length)
+ public void FoldToASCII(char[] input, int length)
{
if (preserveOriginal)
{
- state = captureState();
+ state = CaptureState();
}
// Worst-case length required:
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int maxSizeNeeded = 4 * length;
int maxSizeNeeded = 4 * length;
if (output.Length < maxSizeNeeded)
{
- output = new char[ArrayUtil.oversize(maxSizeNeeded, RamUsageEstimator.NUM_BYTES_CHAR)];
+ output = new char[ArrayUtil.Oversize(maxSizeNeeded, RamUsageEstimator.NUM_BYTES_CHAR)];
}
- outputPos = foldToASCII(input, 0, output, 0, length);
+ outputPos = FoldToASCII(input, 0, output, 0, length);
}
/// <summary>
@@ -178,15 +162,11 @@ namespace org.apache.lucene.analysis.miscellaneous
/// <param name="length"> The number of characters to fold </param>
/// <returns> length of output
/// @lucene.internal </returns>
- public static int foldToASCII(char[] input, int inputPos, char[] output, int outputPos, int length)
+ public static int FoldToASCII(char[] input, int inputPos, char[] output, int outputPos, int length)
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int end = inputPos + length;
int end = inputPos + length;
for (int pos = inputPos; pos < end ; ++pos)
{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final char c = input[pos];
char c = input[pos];
// Quick test: if it's not in range then just keep current character
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ASCIIFoldingFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ASCIIFoldingFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ASCIIFoldingFilterFactory.cs
index 17d787a..d431ee7 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ASCIIFoldingFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ASCIIFoldingFilterFactory.cs
@@ -1,8 +1,7 @@
using System.Collections.Generic;
using Lucene.Net.Analysis.Util;
-using TokenFilterFactory = Lucene.Net.Analysis.Util.TokenFilterFactory;
-namespace org.apache.lucene.analysis.miscellaneous
+namespace Lucene.Net.Analysis.Miscellaneous
{
/*
@@ -21,12 +20,7 @@ namespace org.apache.lucene.analysis.miscellaneous
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- using AbstractAnalysisFactory = AbstractAnalysisFactory;
- using MultiTermAwareComponent = org.apache.lucene.analysis.util.MultiTermAwareComponent;
- using TokenFilterFactory = TokenFilterFactory;
-
- /// <summary>
+ /// <summary>
/// Factory for <seealso cref="ASCIIFoldingFilter"/>.
/// <pre class="prettyprint">
/// <fieldType name="text_ascii" class="solr.TextField" positionIncrementGap="100">
@@ -51,7 +45,7 @@ namespace org.apache.lucene.analysis.miscellaneous
}
}
- public override ASCIIFoldingFilter create(TokenStream input)
+ public override TokenStream Create(TokenStream input)
{
return new ASCIIFoldingFilter(input, preserveOriginal);
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CapitalizationFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CapitalizationFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CapitalizationFilter.cs
index 94c8d4b..9264435 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CapitalizationFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CapitalizationFilter.cs
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
+using Lucene.Net.Analysis.Tokenattributes;
+using Lucene.Net.Analysis.Util;
-namespace org.apache.lucene.analysis.miscellaneous
+namespace Lucene.Net.Analysis.Miscellaneous
{
/*
@@ -20,12 +22,7 @@ namespace org.apache.lucene.analysis.miscellaneous
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
-
- using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
- using CharArraySet = org.apache.lucene.analysis.util.CharArraySet;
-
- /// <summary>
+ /// <summary>
/// A filter to apply normal capitalization rules to Tokens. It will make the first letter
/// capital and the rest lower case.
/// <p/>
@@ -82,17 +79,15 @@ namespace org.apache.lucene.analysis.miscellaneous
this.maxTokenLength = maxTokenLength;
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public boolean incrementToken() throws java.io.IOException
- public override bool incrementToken()
+ public override bool IncrementToken()
{
- if (!input.incrementToken())
+ if (!input.IncrementToken())
{
return false;
}
- char[] termBuffer = termAtt.buffer();
- int termBufferLength = termAtt.length();
+ char[] termBuffer = termAtt.Buffer();
+ int termBufferLength = termAtt.Length;
char[] backup = null;
if (maxWordCount < DEFAULT_MAX_WORD_COUNT)
@@ -115,7 +110,7 @@ namespace org.apache.lucene.analysis.miscellaneous
int len = i - lastWordStart;
if (len > 0)
{
- processWord(termBuffer, lastWordStart, len, wordCount++);
+ ProcessWord(termBuffer, lastWordStart, len, wordCount++);
lastWordStart = i + 1;
i++;
}
@@ -125,19 +120,19 @@ namespace org.apache.lucene.analysis.miscellaneous
// process the last word
if (lastWordStart < termBufferLength)
{
- processWord(termBuffer, lastWordStart, termBufferLength - lastWordStart, wordCount++);
+ ProcessWord(termBuffer, lastWordStart, termBufferLength - lastWordStart, wordCount++);
}
if (wordCount > maxWordCount)
{
- termAtt.copyBuffer(backup, 0, termBufferLength);
+ termAtt.CopyBuffer(backup, 0, termBufferLength);
}
}
return true;
}
- private void processWord(char[] buffer, int offset, int length, int wordCount)
+ private void ProcessWord(char[] buffer, int offset, int length, int wordCount)
{
if (length < 1)
{
@@ -154,7 +149,7 @@ namespace org.apache.lucene.analysis.miscellaneous
return;
}
- if (keep != null && keep.contains(buffer, offset, length))
+ if (keep != null && keep.Contains(buffer, offset, length))
{
if (wordCount == 0 && forceFirstLetter)
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CapitalizationFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CapitalizationFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CapitalizationFilterFactory.cs
index bd4f335..fccc4db 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CapitalizationFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CapitalizationFilterFactory.cs
@@ -1,117 +1,114 @@
using System.Collections.Generic;
-using TokenFilterFactory = Lucene.Net.Analysis.Util.TokenFilterFactory;
+using Lucene.Net.Analysis.Util;
+using Lucene.Net.Support;
+using org.apache.lucene.analysis.miscellaneous;
-namespace org.apache.lucene.analysis.miscellaneous
+namespace Lucene.Net.Analysis.Miscellaneous
{
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ /// <summary>
+ /// Factory for <seealso cref="CapitalizationFilter"/>.
+ /// <p/>
+ /// The factory takes parameters:<br/>
+ /// "onlyFirstWord" - should each word be capitalized or all of the words?<br/>
+ /// "keep" - a keep word list. Each word that should be kept separated by whitespace.<br/>
+ /// "keepIgnoreCase - true or false. If true, the keep list will be considered case-insensitive.<br/>
+ /// "forceFirstLetter" - Force the first letter to be capitalized even if it is in the keep list<br/>
+ /// "okPrefix" - do not change word capitalization if a word begins with something in this list.
+ /// for example if "McK" is on the okPrefix list, the word "McKinley" should not be changed to
+ /// "Mckinley"<br/>
+ /// "minWordLength" - how long the word needs to be to get capitalization applied. If the
+ /// minWordLength is 3, "and" > "And" but "or" stays "or"<br/>
+ /// "maxWordCount" - if the token contains more then maxWordCount words, the capitalization is
+ /// assumed to be correct.<br/>
+ ///
+ /// <pre class="prettyprint">
+ /// <fieldType name="text_cptlztn" class="solr.TextField" positionIncrementGap="100">
+ /// <analyzer>
+ /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
+ /// <filter class="solr.CapitalizationFilterFactory" onlyFirstWord="true"
+ /// keep="java solr lucene" keepIgnoreCase="false"
+ /// okPrefix="McK McD McA"/>
+ /// </analyzer>
+ /// </fieldType></pre>
+ ///
+ /// @since solr 1.3
+ /// </summary>
+ public class CapitalizationFilterFactory : TokenFilterFactory
+ {
+ public const string KEEP = "keep";
+ public const string KEEP_IGNORE_CASE = "keepIgnoreCase";
+ public const string OK_PREFIX = "okPrefix";
+ public const string MIN_WORD_LENGTH = "minWordLength";
+ public const string MAX_WORD_COUNT = "maxWordCount";
+ public const string MAX_TOKEN_LENGTH = "maxTokenLength";
+ public const string ONLY_FIRST_WORD = "onlyFirstWord";
+ public const string FORCE_FIRST_LETTER = "forceFirstLetter";
- using CharArraySet = org.apache.lucene.analysis.util.CharArraySet;
- using TokenFilterFactory = TokenFilterFactory;
+ internal CharArraySet keep;
+ internal ICollection<char[]> okPrefix = Collections.EmptyList<char[]>(); // for Example: McK
- /// <summary>
- /// Factory for <seealso cref="CapitalizationFilter"/>.
- /// <p/>
- /// The factory takes parameters:<br/>
- /// "onlyFirstWord" - should each word be capitalized or all of the words?<br/>
- /// "keep" - a keep word list. Each word that should be kept separated by whitespace.<br/>
- /// "keepIgnoreCase - true or false. If true, the keep list will be considered case-insensitive.<br/>
- /// "forceFirstLetter" - Force the first letter to be capitalized even if it is in the keep list<br/>
- /// "okPrefix" - do not change word capitalization if a word begins with something in this list.
- /// for example if "McK" is on the okPrefix list, the word "McKinley" should not be changed to
- /// "Mckinley"<br/>
- /// "minWordLength" - how long the word needs to be to get capitalization applied. If the
- /// minWordLength is 3, "and" > "And" but "or" stays "or"<br/>
- /// "maxWordCount" - if the token contains more then maxWordCount words, the capitalization is
- /// assumed to be correct.<br/>
- ///
- /// <pre class="prettyprint">
- /// <fieldType name="text_cptlztn" class="solr.TextField" positionIncrementGap="100">
- /// <analyzer>
- /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
- /// <filter class="solr.CapitalizationFilterFactory" onlyFirstWord="true"
- /// keep="java solr lucene" keepIgnoreCase="false"
- /// okPrefix="McK McD McA"/>
- /// </analyzer>
- /// </fieldType></pre>
- ///
- /// @since solr 1.3
- /// </summary>
- public class CapitalizationFilterFactory : TokenFilterFactory
- {
- public const string KEEP = "keep";
- public const string KEEP_IGNORE_CASE = "keepIgnoreCase";
- public const string OK_PREFIX = "okPrefix";
- public const string MIN_WORD_LENGTH = "minWordLength";
- public const string MAX_WORD_COUNT = "maxWordCount";
- public const string MAX_TOKEN_LENGTH = "maxTokenLength";
- public const string ONLY_FIRST_WORD = "onlyFirstWord";
- public const string FORCE_FIRST_LETTER = "forceFirstLetter";
+ internal readonly int minWordLength; // don't modify capitalization for words shorter then this
+ internal readonly int maxWordCount;
+ internal readonly int maxTokenLength;
+ internal readonly bool onlyFirstWord;
+ internal readonly bool forceFirstLetter; // make sure the first letter is capital even if it is in the keep list
- internal CharArraySet keep;
+ /// <summary>
+ /// Creates a new CapitalizationFilterFactory </summary>
+ public CapitalizationFilterFactory(IDictionary<string, string> args)
+ : base(args)
+ {
+ assureMatchVersion();
+ bool ignoreCase = getBoolean(args, KEEP_IGNORE_CASE, false);
+ HashSet<string> k = getSet(args, KEEP);
+ if (k != null)
+ {
+ keep = new CharArraySet(luceneMatchVersion, 10, ignoreCase);
+ keep.AddAll(k);
+ }
- internal ICollection<char[]> okPrefix = Collections.emptyList(); // for Example: McK
+ k = getSet(args, OK_PREFIX);
+ if (k != null)
+ {
+ okPrefix = new List<char[]>();
+ foreach (string item in k)
+ {
+ okPrefix.Add(item.ToCharArray());
+ }
+ }
- internal readonly int minWordLength; // don't modify capitalization for words shorter then this
- internal readonly int maxWordCount;
- internal readonly int maxTokenLength;
- internal readonly bool onlyFirstWord;
- internal readonly bool forceFirstLetter; // make sure the first letter is capital even if it is in the keep list
-
- /// <summary>
- /// Creates a new CapitalizationFilterFactory </summary>
- public CapitalizationFilterFactory(IDictionary<string, string> args) : base(args)
- {
- assureMatchVersion();
- bool ignoreCase = getBoolean(args, KEEP_IGNORE_CASE, false);
- HashSet<string> k = getSet(args, KEEP);
- if (k != null)
- {
- keep = new CharArraySet(luceneMatchVersion, 10, ignoreCase);
- keep.addAll(k);
- }
-
- k = getSet(args, OK_PREFIX);
- if (k != null)
- {
- okPrefix = new List<>();
- foreach (string item in k)
- {
- okPrefix.Add(item.ToCharArray());
- }
- }
-
- minWordLength = getInt(args, MIN_WORD_LENGTH, 0);
- maxWordCount = getInt(args, MAX_WORD_COUNT, CapitalizationFilter.DEFAULT_MAX_WORD_COUNT);
- maxTokenLength = getInt(args, MAX_TOKEN_LENGTH, CapitalizationFilter.DEFAULT_MAX_TOKEN_LENGTH);
- onlyFirstWord = getBoolean(args, ONLY_FIRST_WORD, true);
- forceFirstLetter = getBoolean(args, FORCE_FIRST_LETTER, true);
- if (args.Count > 0)
- {
- throw new System.ArgumentException("Unknown parameters: " + args);
- }
- }
-
- public override CapitalizationFilter create(TokenStream input)
- {
- return new CapitalizationFilter(input, onlyFirstWord, keep, forceFirstLetter, okPrefix, minWordLength, maxWordCount, maxTokenLength);
- }
- }
+ minWordLength = getInt(args, MIN_WORD_LENGTH, 0);
+ maxWordCount = getInt(args, MAX_WORD_COUNT, CapitalizationFilter.DEFAULT_MAX_WORD_COUNT);
+ maxTokenLength = getInt(args, MAX_TOKEN_LENGTH, CapitalizationFilter.DEFAULT_MAX_TOKEN_LENGTH);
+ onlyFirstWord = getBoolean(args, ONLY_FIRST_WORD, true);
+ forceFirstLetter = getBoolean(args, FORCE_FIRST_LETTER, true);
+ if (args.Count > 0)
+ {
+ throw new System.ArgumentException("Unknown parameters: " + args);
+ }
+ }
+ public override TokenStream Create(TokenStream input)
+ {
+ return new CapitalizationFilter(input, onlyFirstWord, keep, forceFirstLetter, okPrefix, minWordLength, maxWordCount, maxTokenLength);
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeepWordFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeepWordFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeepWordFilter.cs
index f110d37..f9f9a53 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeepWordFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeepWordFilter.cs
@@ -1,5 +1,6 @@
using System;
-using FilteringTokenFilter = Lucene.Net.Analysis.Util.FilteringTokenFilter;
+using Lucene.Net.Analysis.Tokenattributes;
+using Lucene.Net.Analysis.Util;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -18,50 +19,45 @@ using FilteringTokenFilter = Lucene.Net.Analysis.Util.FilteringTokenFilter;
* limitations under the License.
*/
-namespace org.apache.lucene.analysis.miscellaneous
+namespace Lucene.Net.Analysis.Miscellaneous
{
-
- using FilteringTokenFilter = FilteringTokenFilter;
- using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
- using CharArraySet = org.apache.lucene.analysis.util.CharArraySet;
- using Version = org.apache.lucene.util.Version;
-
- /// <summary>
- /// A TokenFilter that only keeps tokens with text contained in the
- /// required words. This filter behaves like the inverse of StopFilter.
- ///
- /// @since solr 1.3
- /// </summary>
- public sealed class KeepWordFilter : FilteringTokenFilter
- {
- private readonly CharArraySet words;
- private readonly CharTermAttribute termAtt = addAttribute(typeof(CharTermAttribute));
-
- /// @deprecated enablePositionIncrements=false is not supported anymore as of Lucene 4.4.
- [Obsolete("enablePositionIncrements=false is not supported anymore as of Lucene 4.4.")]
- public KeepWordFilter(Version version, bool enablePositionIncrements, TokenStream @in, CharArraySet words) : base(version, enablePositionIncrements, @in)
- {
- this.words = words;
- }
-
- /// <summary>
- /// Create a new <seealso cref="KeepWordFilter"/>.
- /// <para><b>NOTE</b>: The words set passed to this constructor will be directly
- /// used by this filter and should not be modified.
- /// </para>
- /// </summary>
- /// <param name="version"> the Lucene match version </param>
- /// <param name="in"> the <seealso cref="TokenStream"/> to consume </param>
- /// <param name="words"> the words to keep </param>
- public KeepWordFilter(Version version, TokenStream @in, CharArraySet words) : base(version, @in)
- {
- this.words = words;
- }
-
- public override bool accept()
- {
- return words.contains(termAtt.buffer(), 0, termAtt.length());
- }
- }
-
+ /// <summary>
+ /// A TokenFilter that only keeps tokens with text contained in the
+ /// required words. This filter behaves like the inverse of StopFilter.
+ ///
+ /// @since solr 1.3
+ /// </summary>
+ public sealed class KeepWordFilter : FilteringTokenFilter
+ {
+ private readonly CharArraySet words;
+ private readonly CharTermAttribute termAtt = addAttribute(typeof(CharTermAttribute));
+
+ /// @deprecated enablePositionIncrements=false is not supported anymore as of Lucene 4.4.
+ [Obsolete("enablePositionIncrements=false is not supported anymore as of Lucene 4.4.")]
+ public KeepWordFilter(Version version, bool enablePositionIncrements, TokenStream @in, CharArraySet words)
+ : base(version, enablePositionIncrements, @in)
+ {
+ this.words = words;
+ }
+
+ /// <summary>
+ /// Create a new <seealso cref="KeepWordFilter"/>.
+ /// <para><b>NOTE</b>: The words set passed to this constructor will be directly
+ /// used by this filter and should not be modified.
+ /// </para>
+ /// </summary>
+ /// <param name="version"> the Lucene match version </param>
+ /// <param name="in"> the <seealso cref="TokenStream"/> to consume </param>
+ /// <param name="words"> the words to keep </param>
+ public KeepWordFilter(Version version, TokenStream @in, CharArraySet words)
+ : base(version, @in)
+ {
+ this.words = words;
+ }
+
+ public override bool Accept()
+ {
+ return words.Contains(termAtt.Buffer(), 0, termAtt.Length);
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeepWordFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeepWordFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeepWordFilterFactory.cs
index 8aa687f..266f4b9 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeepWordFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeepWordFilterFactory.cs
@@ -1,113 +1,103 @@
using System.Collections.Generic;
-using TokenFilterFactory = Lucene.Net.Analysis.Util.TokenFilterFactory;
+using Lucene.Net.Analysis.Util;
+using org.apache.lucene.analysis.miscellaneous;
+using org.apache.lucene.analysis.util;
-namespace org.apache.lucene.analysis.miscellaneous
+namespace Lucene.Net.Analysis.Miscellaneous
{
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ /// <summary>
+ /// Factory for <seealso cref="KeepWordFilter"/>.
+ /// <pre class="prettyprint">
+ /// <fieldType name="text_keepword" class="solr.TextField" positionIncrementGap="100">
+ /// <analyzer>
+ /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
+ /// <filter class="solr.KeepWordFilterFactory" words="keepwords.txt" ignoreCase="false"/>
+ /// </analyzer>
+ /// </fieldType></pre>
+ /// </summary>
+ public class KeepWordFilterFactory : TokenFilterFactory, ResourceLoaderAware
+ {
+ private readonly bool ignoreCase;
+ private readonly bool enablePositionIncrements;
+ private readonly string wordFiles;
+ private CharArraySet words;
- using CharArraySet = org.apache.lucene.analysis.util.CharArraySet;
- using ResourceLoader = org.apache.lucene.analysis.util.ResourceLoader;
- using ResourceLoaderAware = org.apache.lucene.analysis.util.ResourceLoaderAware;
- using TokenFilterFactory = TokenFilterFactory;
+ /// <summary>
+ /// Creates a new KeepWordFilterFactory </summary>
+ public KeepWordFilterFactory(IDictionary<string, string> args)
+ : base(args)
+ {
+ assureMatchVersion();
+ wordFiles = get(args, "words");
+ ignoreCase = getBoolean(args, "ignoreCase", false);
+ enablePositionIncrements = getBoolean(args, "enablePositionIncrements", true);
+ if (args.Count > 0)
+ {
+ throw new System.ArgumentException("Unknown parameters: " + args);
+ }
+ }
+ public virtual void Inform(ResourceLoader loader)
+ {
+ if (wordFiles != null)
+ {
+ words = GetWordSet(loader, wordFiles, ignoreCase);
+ }
+ }
- /// <summary>
- /// Factory for <seealso cref="KeepWordFilter"/>.
- /// <pre class="prettyprint">
- /// <fieldType name="text_keepword" class="solr.TextField" positionIncrementGap="100">
- /// <analyzer>
- /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
- /// <filter class="solr.KeepWordFilterFactory" words="keepwords.txt" ignoreCase="false"/>
- /// </analyzer>
- /// </fieldType></pre>
- /// </summary>
- public class KeepWordFilterFactory : TokenFilterFactory, ResourceLoaderAware
- {
- private readonly bool ignoreCase;
- private readonly bool enablePositionIncrements;
- private readonly string wordFiles;
- private CharArraySet words;
+ public virtual bool EnablePositionIncrements
+ {
+ get
+ {
+ return enablePositionIncrements;
+ }
+ }
- /// <summary>
- /// Creates a new KeepWordFilterFactory </summary>
- public KeepWordFilterFactory(IDictionary<string, string> args) : base(args)
- {
- assureMatchVersion();
- wordFiles = get(args, "words");
- ignoreCase = getBoolean(args, "ignoreCase", false);
- enablePositionIncrements = getBoolean(args, "enablePositionIncrements", true);
- if (args.Count > 0)
- {
- throw new System.ArgumentException("Unknown parameters: " + args);
- }
- }
+ public virtual bool IgnoreCase
+ {
+ get
+ {
+ return ignoreCase;
+ }
+ }
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public void inform(org.apache.lucene.analysis.util.ResourceLoader loader) throws java.io.IOException
- public virtual void inform(ResourceLoader loader)
- {
- if (wordFiles != null)
- {
- words = getWordSet(loader, wordFiles, ignoreCase);
- }
- }
-
- public virtual bool EnablePositionIncrements
- {
- get
- {
- return enablePositionIncrements;
- }
- }
-
- public virtual bool IgnoreCase
- {
- get
- {
- return ignoreCase;
- }
- }
-
- public virtual CharArraySet Words
- {
- get
- {
- return words;
- }
- }
-
- public override TokenStream create(TokenStream input)
- {
- // if the set is null, it means it was empty
- if (words == null)
- {
- return input;
- }
- else
- {
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
-//ORIGINAL LINE: @SuppressWarnings("deprecation") final org.apache.lucene.analysis.TokenStream filter = new KeepWordFilter(luceneMatchVersion, enablePositionIncrements, input, words);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
- TokenStream filter = new KeepWordFilter(luceneMatchVersion, enablePositionIncrements, input, words);
- return filter;
- }
- }
- }
+ public virtual CharArraySet Words
+ {
+ get
+ {
+ return words;
+ }
+ }
+ public override TokenStream Create(TokenStream input)
+ {
+ // if the set is null, it means it was empty
+ if (words == null)
+ {
+ return input;
+ }
+ else
+ {
+ TokenStream filter = new KeepWordFilter(luceneMatchVersion, enablePositionIncrements, input, words);
+ return filter;
+ }
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeywordMarkerFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeywordMarkerFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeywordMarkerFilterFactory.cs
index 14eeafa..c374fae 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeywordMarkerFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeywordMarkerFilterFactory.cs
@@ -1,99 +1,91 @@
using System.Collections.Generic;
-using TokenFilterFactory = Lucene.Net.Analysis.Util.TokenFilterFactory;
+using Lucene.Net.Analysis.Util;
+using org.apache.lucene.analysis.miscellaneous;
-namespace org.apache.lucene.analysis.miscellaneous
+namespace Lucene.Net.Analysis.Miscellaneous
{
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ /// <summary>
+ /// Factory for <seealso cref="KeywordMarkerFilter"/>.
+ /// <pre class="prettyprint">
+ /// <fieldType name="text_keyword" class="solr.TextField" positionIncrementGap="100">
+ /// <analyzer>
+ /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
+ /// <filter class="solr.KeywordMarkerFilterFactory" protected="protectedkeyword.txt" pattern="^.+er$" ignoreCase="false"/>
+ /// </analyzer>
+ /// </fieldType></pre>
+ /// </summary>
+ public class KeywordMarkerFilterFactory : TokenFilterFactory, ResourceLoaderAware
+ {
+ public const string PROTECTED_TOKENS = "protected";
+ public const string PATTERN = "pattern";
+ private readonly string wordFiles;
+ private readonly string stringPattern;
+ private readonly bool ignoreCase;
+ private Pattern pattern;
+ private CharArraySet protectedWords;
+ /// <summary>
+ /// Creates a new KeywordMarkerFilterFactory </summary>
+ public KeywordMarkerFilterFactory(IDictionary<string, string> args)
+ : base(args)
+ {
+ wordFiles = get(args, PROTECTED_TOKENS);
+ stringPattern = get(args, PATTERN);
+ ignoreCase = getBoolean(args, "ignoreCase", false);
+ if (args.Count > 0)
+ {
+ throw new System.ArgumentException("Unknown parameters: " + args);
+ }
+ }
- using CharArraySet = org.apache.lucene.analysis.util.CharArraySet;
- using ResourceLoader = org.apache.lucene.analysis.util.ResourceLoader;
- using ResourceLoaderAware = org.apache.lucene.analysis.util.ResourceLoaderAware;
- using TokenFilterFactory = TokenFilterFactory;
+ public virtual void Inform(ResourceLoader loader)
+ {
+ if (wordFiles != null)
+ {
+ protectedWords = GetWordSet(loader, wordFiles, ignoreCase);
+ }
+ if (stringPattern != null)
+ {
+ pattern = ignoreCase ? Pattern.compile(stringPattern, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : Pattern.compile(stringPattern);
+ }
+ }
- /// <summary>
- /// Factory for <seealso cref="KeywordMarkerFilter"/>.
- /// <pre class="prettyprint">
- /// <fieldType name="text_keyword" class="solr.TextField" positionIncrementGap="100">
- /// <analyzer>
- /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
- /// <filter class="solr.KeywordMarkerFilterFactory" protected="protectedkeyword.txt" pattern="^.+er$" ignoreCase="false"/>
- /// </analyzer>
- /// </fieldType></pre>
- /// </summary>
- public class KeywordMarkerFilterFactory : TokenFilterFactory, ResourceLoaderAware
- {
- public const string PROTECTED_TOKENS = "protected";
- public const string PATTERN = "pattern";
- private readonly string wordFiles;
- private readonly string stringPattern;
- private readonly bool ignoreCase;
- private Pattern pattern;
- private CharArraySet protectedWords;
-
- /// <summary>
- /// Creates a new KeywordMarkerFilterFactory </summary>
- public KeywordMarkerFilterFactory(IDictionary<string, string> args) : base(args)
- {
- wordFiles = get(args, PROTECTED_TOKENS);
- stringPattern = get(args, PATTERN);
- ignoreCase = getBoolean(args, "ignoreCase", false);
- if (args.Count > 0)
- {
- throw new System.ArgumentException("Unknown parameters: " + args);
- }
- }
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public void inform(org.apache.lucene.analysis.util.ResourceLoader loader) throws java.io.IOException
- public virtual void inform(ResourceLoader loader)
- {
- if (wordFiles != null)
- {
- protectedWords = getWordSet(loader, wordFiles, ignoreCase);
- }
- if (stringPattern != null)
- {
- pattern = ignoreCase ? Pattern.compile(stringPattern, Pattern.CASE_INSENSITIVE | Pattern.UNICODE_CASE) : Pattern.compile(stringPattern);
- }
- }
-
- public virtual bool IgnoreCase
- {
- get
- {
- return ignoreCase;
- }
- }
-
- public override TokenStream create(TokenStream input)
- {
- if (pattern != null)
- {
- input = new PatternKeywordMarkerFilter(input, pattern);
- }
- if (protectedWords != null)
- {
- input = new SetKeywordMarkerFilter(input, protectedWords);
- }
- return input;
- }
- }
+ public virtual bool IgnoreCase
+ {
+ get
+ {
+ return ignoreCase;
+ }
+ }
+ public override TokenStream Create(TokenStream input)
+ {
+ if (pattern != null)
+ {
+ input = new PatternKeywordMarkerFilter(input, pattern);
+ }
+ if (protectedWords != null)
+ {
+ input = new SetKeywordMarkerFilter(input, protectedWords);
+ }
+ return input;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeywordRepeatFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeywordRepeatFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeywordRepeatFilterFactory.cs
index b6f7b86..1e97350 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeywordRepeatFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeywordRepeatFilterFactory.cs
@@ -1,52 +1,51 @@
using System.Collections.Generic;
-using TokenFilterFactory = Lucene.Net.Analysis.Util.TokenFilterFactory;
+using Lucene.Net.Analysis.Util;
+using org.apache.lucene.analysis.miscellaneous;
-namespace org.apache.lucene.analysis.miscellaneous
+namespace Lucene.Net.Analysis.Miscellaneous
{
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ /// <summary>
+ /// Factory for <seealso cref="KeywordRepeatFilter"/>.
+ ///
+ /// Since <seealso cref="KeywordRepeatFilter"/> emits two tokens for every input token, and any tokens that aren't transformed
+ /// later in the analysis chain will be in the document twice. Therefore, consider adding
+ /// <seealso cref="RemoveDuplicatesTokenFilterFactory"/> later in the analysis chain.
+ /// </summary>
+ public sealed class KeywordRepeatFilterFactory : TokenFilterFactory
+ {
- using TokenFilterFactory = TokenFilterFactory;
+ /// <summary>
+ /// Creates a new KeywordRepeatFilterFactory </summary>
+ public KeywordRepeatFilterFactory(IDictionary<string, string> args)
+ : base(args)
+ {
+ if (args.Count > 0)
+ {
+ throw new System.ArgumentException("Unknown parameters: " + args);
+ }
+ }
- /// <summary>
- /// Factory for <seealso cref="KeywordRepeatFilter"/>.
- ///
- /// Since <seealso cref="KeywordRepeatFilter"/> emits two tokens for every input token, and any tokens that aren't transformed
- /// later in the analysis chain will be in the document twice. Therefore, consider adding
- /// <seealso cref="RemoveDuplicatesTokenFilterFactory"/> later in the analysis chain.
- /// </summary>
- public sealed class KeywordRepeatFilterFactory : TokenFilterFactory
- {
-
- /// <summary>
- /// Creates a new KeywordRepeatFilterFactory </summary>
- public KeywordRepeatFilterFactory(IDictionary<string, string> args) : base(args)
- {
- if (args.Count > 0)
- {
- throw new System.ArgumentException("Unknown parameters: " + args);
- }
- }
-
- public override TokenStream create(TokenStream input)
- {
- return new KeywordRepeatFilter(input);
- }
- }
+ public override TokenStream Create(TokenStream input)
+ {
+ return new KeywordRepeatFilter(input);
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/Lucene47WordDelimiterFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/Lucene47WordDelimiterFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/Lucene47WordDelimiterFilter.cs
index fa5d5da..da3bda4 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/Lucene47WordDelimiterFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/Lucene47WordDelimiterFilter.cs
@@ -17,6 +17,7 @@ using System.Text;
* limitations under the License.
*/
using Lucene.Net.Analysis.Core;
+using Lucene.Net.Analysis.Util;
namespace org.apache.lucene.analysis.miscellaneous
{
@@ -27,7 +28,7 @@ namespace org.apache.lucene.analysis.miscellaneous
using PositionIncrementAttribute = org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
using TypeAttribute = org.apache.lucene.analysis.tokenattributes.TypeAttribute;
- using CharArraySet = org.apache.lucene.analysis.util.CharArraySet;
+ using CharArraySet = CharArraySet;
using ArrayUtil = org.apache.lucene.util.ArrayUtil;
using RamUsageEstimator = org.apache.lucene.util.RamUsageEstimator;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/PatternAnalyzer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/PatternAnalyzer.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/PatternAnalyzer.cs
index 77cbe8e..d074038 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/PatternAnalyzer.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/PatternAnalyzer.cs
@@ -1,5 +1,6 @@
using System;
using Lucene.Net.Analysis.Core;
+using Lucene.Net.Analysis.Util;
namespace org.apache.lucene.analysis.miscellaneous
{
@@ -26,7 +27,7 @@ namespace org.apache.lucene.analysis.miscellaneous
using StopFilter = StopFilter;
using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
using OffsetAttribute = org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
- using CharArraySet = org.apache.lucene.analysis.util.CharArraySet;
+ using CharArraySet = CharArraySet;
using Version = org.apache.lucene.util.Version;
/// <summary>
@@ -109,7 +110,7 @@ namespace org.apache.lucene.analysis.miscellaneous
/// given stop set (after previously having applied toLowerCase()
/// if applicable). For example, created via
/// <seealso cref="StopFilter#makeStopSet(Version, String[])"/>and/or
- /// <seealso cref="org.apache.lucene.analysis.util.WordlistLoader"/>as in
+ /// <seealso cref="WordlistLoader"/>as in
/// <code>WordlistLoader.getWordSet(new File("samples/fulltext/stopwords.txt")</code>
/// or <a href="http://www.unine.ch/info/clef/">other stop words
/// lists </a>. </param>
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/RemoveDuplicatesTokenFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/RemoveDuplicatesTokenFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/RemoveDuplicatesTokenFilter.cs
index 9c2586f..b4a5c90 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/RemoveDuplicatesTokenFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/RemoveDuplicatesTokenFilter.cs
@@ -1,6 +1,4 @@
-using System;
-
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -17,83 +15,72 @@
* limitations under the License.
*/
-namespace org.apache.lucene.analysis.miscellaneous
-{
-
- using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
- using PositionIncrementAttribute = org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
- using CharArraySet = org.apache.lucene.analysis.util.CharArraySet;
- using Version = org.apache.lucene.util.Version;
+using System;
+using Lucene.Net.Analysis.Tokenattributes;
+using Lucene.Net.Analysis.Util;
+using Version = Lucene.Net.Util.Version;
- /// <summary>
- /// A TokenFilter which filters out Tokens at the same position and Term text as the previous token in the stream.
- /// </summary>
- public sealed class RemoveDuplicatesTokenFilter : TokenFilter
- {
-
- private readonly CharTermAttribute termAttribute = addAttribute(typeof(CharTermAttribute));
- private readonly PositionIncrementAttribute posIncAttribute = addAttribute(typeof(PositionIncrementAttribute));
+namespace Lucene.Net.Analysis.Miscellaneous
+{
+ /// <summary>
+ /// A TokenFilter which filters out Tokens at the same position and Term text as the previous token in the stream.
+ /// </summary>
+ public sealed class RemoveDuplicatesTokenFilter : TokenFilter
+ {
- // use a fixed version, as we don't care about case sensitivity.
- private readonly CharArraySet previous = new CharArraySet(Version.LUCENE_31, 8, false);
+ private readonly CharTermAttribute termAttribute = addAttribute(typeof(CharTermAttribute));
+ private readonly PositionIncrementAttribute posIncAttribute = addAttribute(typeof(PositionIncrementAttribute));
- /// <summary>
- /// Creates a new RemoveDuplicatesTokenFilter
- /// </summary>
- /// <param name="in"> TokenStream that will be filtered </param>
- public RemoveDuplicatesTokenFilter(TokenStream @in) : base(@in)
- {
- }
+ // use a fixed version, as we don't care about case sensitivity.
+ private readonly CharArraySet previous = new CharArraySet(Version.LUCENE_31, 8, false);
- /// <summary>
- /// {@inheritDoc}
- /// </summary>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public boolean incrementToken() throws java.io.IOException
- public override bool incrementToken()
- {
- while (input.incrementToken())
- {
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final char term[] = termAttribute.buffer();
- char[] term = termAttribute.buffer();
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int length = termAttribute.length();
- int length = termAttribute.length();
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int posIncrement = posIncAttribute.getPositionIncrement();
- int posIncrement = posIncAttribute.PositionIncrement;
+ /// <summary>
+ /// Creates a new RemoveDuplicatesTokenFilter
+ /// </summary>
+ /// <param name="in"> TokenStream that will be filtered </param>
+ public RemoveDuplicatesTokenFilter(TokenStream @in)
+ : base(@in)
+ {
+ }
- if (posIncrement > 0)
- {
- previous.clear();
- }
+ /// <summary>
+ /// {@inheritDoc}
+ /// </summary>
+ public override bool IncrementToken()
+ {
+ while (input.IncrementToken())
+ {
+ char[] term = termAttribute.Buffer();
+ int length = termAttribute.Length;
+ int posIncrement = posIncAttribute.PositionIncrement;
- bool duplicate = (posIncrement == 0 && previous.contains(term, 0, length));
+ if (posIncrement > 0)
+ {
+ previous.Clear();
+ }
- // clone the term, and add to the set of seen terms.
- char[] saved = new char[length];
- Array.Copy(term, 0, saved, 0, length);
- previous.add(saved);
+ bool duplicate = (posIncrement == 0 && previous.Contains(term, 0, length));
- if (!duplicate)
- {
- return true;
- }
- }
- return false;
- }
+ // clone the term, and add to the set of seen terms.
+ char[] saved = new char[length];
+ Array.Copy(term, 0, saved, 0, length);
+ previous.Add(saved);
- /// <summary>
- /// {@inheritDoc}
- /// </summary>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public void reset() throws java.io.IOException
- public override void reset()
- {
- base.reset();
- previous.clear();
- }
- }
+ if (!duplicate)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ /// <summary>
+ /// {@inheritDoc}
+ /// </summary>
+ public override void Reset()
+ {
+ base.Reset();
+ previous.Clear();
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/RemoveDuplicatesTokenFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/RemoveDuplicatesTokenFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/RemoveDuplicatesTokenFilterFactory.cs
index bae261e..f7d5c03 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/RemoveDuplicatesTokenFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/RemoveDuplicatesTokenFilterFactory.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
-using TokenFilterFactory = Lucene.Net.Analysis.Util.TokenFilterFactory;
+using Lucene.Net.Analysis.Util;
-namespace org.apache.lucene.analysis.miscellaneous
+namespace Lucene.Net.Analysis.Miscellaneous
{
/*
@@ -20,10 +20,7 @@ namespace org.apache.lucene.analysis.miscellaneous
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- using TokenFilterFactory = TokenFilterFactory;
-
- /// <summary>
+ /// <summary>
/// Factory for <seealso cref="RemoveDuplicatesTokenFilter"/>.
/// <pre class="prettyprint">
/// <fieldType name="text_rmdup" class="solr.TextField" positionIncrementGap="100">
@@ -46,7 +43,7 @@ namespace org.apache.lucene.analysis.miscellaneous
}
}
- public override RemoveDuplicatesTokenFilter create(TokenStream input)
+ public override RemoveDuplicatesTokenFilter Create(TokenStream input)
{
return new RemoveDuplicatesTokenFilter(input);
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ScandinavianFoldingFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ScandinavianFoldingFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ScandinavianFoldingFilter.cs
index 06ecebc..ffc4ba7 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ScandinavianFoldingFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ScandinavianFoldingFilter.cs
@@ -1,4 +1,6 @@
-namespace org.apache.lucene.analysis.miscellaneous
+using Lucene.Net.Analysis.Util;
+
+namespace org.apache.lucene.analysis.miscellaneous
{
/*
@@ -19,7 +21,7 @@
*/
using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
- using StemmerUtil = org.apache.lucene.analysis.util.StemmerUtil;
+ using StemmerUtil = StemmerUtil;
/// <summary>
/// This filter folds Scandinavian characters åÅäæÄÆ->a and öÖøØ->o.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ScandinavianNormalizationFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ScandinavianNormalizationFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ScandinavianNormalizationFilter.cs
index 3113949..b6bd9de 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ScandinavianNormalizationFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ScandinavianNormalizationFilter.cs
@@ -1,4 +1,6 @@
-namespace org.apache.lucene.analysis.miscellaneous
+using Lucene.Net.Analysis.Util;
+
+namespace org.apache.lucene.analysis.miscellaneous
{
/*
@@ -19,7 +21,7 @@
*/
using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
- using StemmerUtil = org.apache.lucene.analysis.util.StemmerUtil;
+ using StemmerUtil = StemmerUtil;
/// <summary>
/// This filter normalize use of the interchangeable Scandinavian characters æÆäÄöÖøØ
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/SetKeywordMarkerFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/SetKeywordMarkerFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/SetKeywordMarkerFilter.cs
index b732319..c21607b 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/SetKeywordMarkerFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/SetKeywordMarkerFilter.cs
@@ -1,59 +1,56 @@
-namespace org.apache.lucene.analysis.miscellaneous
-{
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
- using KeywordAttribute = org.apache.lucene.analysis.tokenattributes.KeywordAttribute;
- using CharArraySet = org.apache.lucene.analysis.util.CharArraySet;
-
- /// <summary>
- /// Marks terms as keywords via the <seealso cref="KeywordAttribute"/>. Each token
- /// contained in the provided set is marked as a keyword by setting
- /// <seealso cref="KeywordAttribute#setKeyword(boolean)"/> to <code>true</code>.
- /// </summary>
- public sealed class SetKeywordMarkerFilter : KeywordMarkerFilter
- {
- private readonly CharTermAttribute termAtt = addAttribute(typeof(CharTermAttribute));
- private readonly CharArraySet keywordSet;
+using Lucene.Net.Analysis.Tokenattributes;
+using Lucene.Net.Analysis.Util;
+using org.apache.lucene.analysis.miscellaneous;
- /// <summary>
- /// Create a new KeywordSetMarkerFilter, that marks the current token as a
- /// keyword if the tokens term buffer is contained in the given set via the
- /// <seealso cref="KeywordAttribute"/>.
- /// </summary>
- /// <param name="in">
- /// TokenStream to filter </param>
- /// <param name="keywordSet">
- /// the keywords set to lookup the current termbuffer </param>
-//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
-//ORIGINAL LINE: public SetKeywordMarkerFilter(final org.apache.lucene.analysis.TokenStream in, final org.apache.lucene.analysis.util.CharArraySet keywordSet)
- public SetKeywordMarkerFilter(TokenStream @in, CharArraySet keywordSet) : base(@in)
- {
- this.keywordSet = keywordSet;
- }
-
- protected internal override bool Keyword
- {
- get
- {
- return keywordSet.contains(termAtt.buffer(), 0, termAtt.length());
- }
- }
+namespace Lucene.Net.Analysis.Miscellaneous
+{
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ /// <summary>
+ /// Marks terms as keywords via the <seealso cref="KeywordAttribute"/>. Each token
+ /// contained in the provided set is marked as a keyword by setting
+ /// <seealso cref="KeywordAttribute#setKeyword(boolean)"/> to <code>true</code>.
+ /// </summary>
+ public sealed class SetKeywordMarkerFilter : KeywordMarkerFilter
+ {
+ private readonly CharTermAttribute termAtt = addAttribute(typeof(CharTermAttribute));
+ private readonly CharArraySet keywordSet;
- }
+ /// <summary>
+ /// Create a new KeywordSetMarkerFilter, that marks the current token as a
+ /// keyword if the tokens term buffer is contained in the given set via the
+ /// <seealso cref="KeywordAttribute"/>.
+ /// </summary>
+ /// <param name="in">
+ /// TokenStream to filter </param>
+ /// <param name="keywordSet">
+ /// the keywords set to lookup the current termbuffer </param>
+ public SetKeywordMarkerFilter(TokenStream @in, CharArraySet keywordSet)
+ : base(@in)
+ {
+ this.keywordSet = keywordSet;
+ }
+ protected internal override bool Keyword
+ {
+ get
+ {
+ return keywordSet.Contains(termAtt.Buffer(), 0, termAtt.Length);
+ }
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/StemmerOverrideFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/StemmerOverrideFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/StemmerOverrideFilterFactory.cs
index f755c1f..578bf7b 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/StemmerOverrideFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/StemmerOverrideFilterFactory.cs
@@ -1,97 +1,89 @@
using System.Collections.Generic;
-using TokenFilterFactory = Lucene.Net.Analysis.Util.TokenFilterFactory;
+using Lucene.Net.Analysis.Util;
+using org.apache.lucene.analysis.miscellaneous;
-namespace org.apache.lucene.analysis.miscellaneous
+namespace Lucene.Net.Analysis.Miscellaneous
{
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ /// <summary>
+ /// Factory for <seealso cref="StemmerOverrideFilter"/>.
+ /// <pre class="prettyprint">
+ /// <fieldType name="text_dicstem" class="solr.TextField" positionIncrementGap="100">
+ /// <analyzer>
+ /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
+ /// <filter class="solr.StemmerOverrideFilterFactory" dictionary="dictionary.txt" ignoreCase="false"/>
+ /// </analyzer>
+ /// </fieldType></pre>
+ /// </summary>
+ public class StemmerOverrideFilterFactory : TokenFilterFactory, ResourceLoaderAware
+ {
+ private StemmerOverrideFilter.StemmerOverrideMap dictionary;
+ private readonly string dictionaryFiles;
+ private readonly bool ignoreCase;
+ /// <summary>
+ /// Creates a new StemmerOverrideFilterFactory </summary>
+ public StemmerOverrideFilterFactory(IDictionary<string, string> args)
+ : base(args)
+ {
+ dictionaryFiles = get(args, "dictionary");
+ ignoreCase = getBoolean(args, "ignoreCase", false);
+ if (args.Count > 0)
+ {
+ throw new System.ArgumentException("Unknown parameters: " + args);
+ }
+ }
- using StemmerOverrideMap = org.apache.lucene.analysis.miscellaneous.StemmerOverrideFilter.StemmerOverrideMap;
- using ResourceLoader = org.apache.lucene.analysis.util.ResourceLoader;
- using ResourceLoaderAware = org.apache.lucene.analysis.util.ResourceLoaderAware;
- using TokenFilterFactory = TokenFilterFactory;
+ public virtual void Inform(ResourceLoader loader)
+ {
+ if (dictionaryFiles != null)
+ {
+ assureMatchVersion();
+ IList<string> files = splitFileNames(dictionaryFiles);
+ if (files.Count > 0)
+ {
+ StemmerOverrideFilter.Builder builder = new StemmerOverrideFilter.Builder(ignoreCase);
+ foreach (string file in files)
+ {
+ IList<string> list = getLines(loader, file.Trim());
+ foreach (string line in list)
+ {
+ string[] mapping = line.Split("\t", 2);
+ builder.add(mapping[0], mapping[1]);
+ }
+ }
+ dictionary = builder.build();
+ }
+ }
+ }
- /// <summary>
- /// Factory for <seealso cref="StemmerOverrideFilter"/>.
- /// <pre class="prettyprint">
- /// <fieldType name="text_dicstem" class="solr.TextField" positionIncrementGap="100">
- /// <analyzer>
- /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
- /// <filter class="solr.StemmerOverrideFilterFactory" dictionary="dictionary.txt" ignoreCase="false"/>
- /// </analyzer>
- /// </fieldType></pre>
- /// </summary>
- public class StemmerOverrideFilterFactory : TokenFilterFactory, ResourceLoaderAware
- {
- private StemmerOverrideMap dictionary;
- private readonly string dictionaryFiles;
- private readonly bool ignoreCase;
-
- /// <summary>
- /// Creates a new StemmerOverrideFilterFactory </summary>
- public StemmerOverrideFilterFactory(IDictionary<string, string> args) : base(args)
- {
- dictionaryFiles = get(args, "dictionary");
- ignoreCase = getBoolean(args, "ignoreCase", false);
- if (args.Count > 0)
- {
- throw new System.ArgumentException("Unknown parameters: " + args);
- }
- }
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public void inform(org.apache.lucene.analysis.util.ResourceLoader loader) throws java.io.IOException
- public virtual void inform(ResourceLoader loader)
- {
- if (dictionaryFiles != null)
- {
- assureMatchVersion();
- IList<string> files = splitFileNames(dictionaryFiles);
- if (files.Count > 0)
- {
- StemmerOverrideFilter.Builder builder = new StemmerOverrideFilter.Builder(ignoreCase);
- foreach (string file in files)
- {
- IList<string> list = getLines(loader, file.Trim());
- foreach (string line in list)
- {
- string[] mapping = line.Split("\t", 2);
- builder.add(mapping[0], mapping[1]);
- }
- }
- dictionary = builder.build();
- }
- }
- }
-
- public virtual bool IgnoreCase
- {
- get
- {
- return ignoreCase;
- }
- }
-
- public override TokenStream create(TokenStream input)
- {
- return dictionary == null ? input : new StemmerOverrideFilter(input, dictionary);
- }
- }
+ public virtual bool IgnoreCase
+ {
+ get
+ {
+ return ignoreCase;
+ }
+ }
+ public override TokenStream Create(TokenStream input)
+ {
+ return dictionary == null ? input : new StemmerOverrideFilter(input, dictionary);
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/WordDelimiterFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/WordDelimiterFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/WordDelimiterFilter.cs
index 16575e6..2b1811c 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/WordDelimiterFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/WordDelimiterFilter.cs
@@ -17,6 +17,7 @@ using System.Text;
* limitations under the License.
*/
using Lucene.Net.Analysis.Core;
+using Lucene.Net.Analysis.Util;
namespace org.apache.lucene.analysis.miscellaneous
{
@@ -27,7 +28,7 @@ namespace org.apache.lucene.analysis.miscellaneous
using PositionIncrementAttribute = org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
using TypeAttribute = org.apache.lucene.analysis.tokenattributes.TypeAttribute;
- using CharArraySet = org.apache.lucene.analysis.util.CharArraySet;
+ using CharArraySet = CharArraySet;
using ArrayUtil = org.apache.lucene.util.ArrayUtil;
using AttributeSource = org.apache.lucene.util.AttributeSource;
using InPlaceMergeSorter = org.apache.lucene.util.InPlaceMergeSorter;
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/WordDelimiterFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/WordDelimiterFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/WordDelimiterFilterFactory.cs
index 747ed48..d13a3c0 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/WordDelimiterFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/WordDelimiterFilterFactory.cs
@@ -1,8 +1,12 @@
using System;
using System.Collections.Generic;
-using TokenFilterFactory = Lucene.Net.Analysis.Util.TokenFilterFactory;
+using Lucene.Net.Analysis.Util;
+using Lucene.Net.Support;
+using Lucene.Net.Util;
+using org.apache.lucene.analysis.miscellaneous;
+using Version = Lucene.Net.Util.Version;
-namespace org.apache.lucene.analysis.miscellaneous
+namespace Lucene.Net.Analysis.Miscellaneous
{
/*
@@ -21,15 +25,6 @@ namespace org.apache.lucene.analysis.miscellaneous
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
- using CharArraySet = org.apache.lucene.analysis.util.CharArraySet;
- using ResourceLoader = org.apache.lucene.analysis.util.ResourceLoader;
- using ResourceLoaderAware = org.apache.lucene.analysis.util.ResourceLoaderAware;
- using TokenFilterFactory = TokenFilterFactory;
- using Version = org.apache.lucene.util.Version;
-
-
- using org.apache.lucene.analysis.miscellaneous;
//JAVA TO C# CONVERTER TODO TASK: This Java 'import static' statement cannot be converted to C#:
// import static org.apache.lucene.analysis.miscellaneous.WordDelimiterFilter.*;
@@ -109,13 +104,11 @@ namespace org.apache.lucene.analysis.miscellaneous
}
}
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public void inform(org.apache.lucene.analysis.util.ResourceLoader loader) throws java.io.IOException
- public virtual void inform(ResourceLoader loader)
+ public virtual void Inform(ResourceLoader loader)
{
if (wordFiles != null)
{
- protectedWords = getWordSet(loader, wordFiles, false);
+ protectedWords = GetWordSet(loader, wordFiles, false);
}
if (types != null)
{
@@ -130,9 +123,9 @@ namespace org.apache.lucene.analysis.miscellaneous
}
}
- public override TokenFilter create(TokenStream input)
+ public override TokenFilter Create(TokenStream input)
{
- if (luceneMatchVersion.onOrAfter(Version.LUCENE_48))
+ if (luceneMatchVersion.OnOrAfter(Version.LUCENE_48))
{
return new WordDelimiterFilter(luceneMatchVersion, input, typeTable == null ? WordDelimiterIterator.DEFAULT_WORD_DELIM_TABLE : typeTable, flags, protectedWords);
}
@@ -170,19 +163,19 @@ namespace org.apache.lucene.analysis.miscellaneous
}
// ensure the table is always at least as big as DEFAULT_WORD_DELIM_TABLE for performance
- sbyte[] types = new sbyte[Math.Max(typeMap.lastKey() + 1, WordDelimiterIterator.DEFAULT_WORD_DELIM_TABLE.Length)];
+ sbyte[] types = new sbyte[Math.Max(typeMap.LastKey() + 1, WordDelimiterIterator.DEFAULT_WORD_DELIM_TABLE.Length)];
for (int i = 0; i < types.Length; i++)
{
types[i] = WordDelimiterIterator.getType(i);
}
- foreach (KeyValuePair<char?, sbyte?> mapping in typeMap.entrySet())
+ foreach (KeyValuePair<char?, sbyte?> mapping in typeMap.EntrySet())
{
types[mapping.Key] = mapping.Value;
}
return types;
}
- private sbyte? parseType(string s)
+ private sbyte? ParseType(string s)
{
if (s.Equals("LOWER"))
{
@@ -266,5 +259,4 @@ namespace org.apache.lucene.analysis.miscellaneous
return new string(@out, 0, writePos);
}
}
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/cd3ee136/src/Lucene.Net.Analysis.Common/Analysis/Ngram/EdgeNGramFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/EdgeNGramFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/EdgeNGramFilterFactory.cs
index 5b3d94b..64b9ab2 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/EdgeNGramFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/EdgeNGramFilterFactory.cs
@@ -1,61 +1,58 @@
using System.Collections.Generic;
-using TokenFilterFactory = Lucene.Net.Analysis.Util.TokenFilterFactory;
+using Lucene.Net.Analysis.Util;
-namespace org.apache.lucene.analysis.ngram
+namespace Lucene.Net.Analysis.Ngram
{
- /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ /// <summary>
+ /// Creates new instances of <seealso cref="EdgeNGramTokenFilter"/>.
+ /// <pre class="prettyprint">
+ /// <fieldType name="text_edgngrm" class="solr.TextField" positionIncrementGap="100">
+ /// <analyzer>
+ /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
+ /// <filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="1"/>
+ /// </analyzer>
+ /// </fieldType></pre>
+ /// </summary>
+ public class EdgeNGramFilterFactory : TokenFilterFactory
+ {
+ private readonly int maxGramSize;
+ private readonly int minGramSize;
+ private readonly string side;
- using TokenFilterFactory = TokenFilterFactory;
-
- /// <summary>
- /// Creates new instances of <seealso cref="EdgeNGramTokenFilter"/>.
- /// <pre class="prettyprint">
- /// <fieldType name="text_edgngrm" class="solr.TextField" positionIncrementGap="100">
- /// <analyzer>
- /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
- /// <filter class="solr.EdgeNGramFilterFactory" minGramSize="1" maxGramSize="1"/>
- /// </analyzer>
- /// </fieldType></pre>
- /// </summary>
- public class EdgeNGramFilterFactory : TokenFilterFactory
- {
- private readonly int maxGramSize;
- private readonly int minGramSize;
- private readonly string side;
-
- /// <summary>
- /// Creates a new EdgeNGramFilterFactory </summary>
- public EdgeNGramFilterFactory(IDictionary<string, string> args) : base(args)
- {
- minGramSize = getInt(args, "minGramSize", EdgeNGramTokenFilter.DEFAULT_MIN_GRAM_SIZE);
- maxGramSize = getInt(args, "maxGramSize", EdgeNGramTokenFilter.DEFAULT_MAX_GRAM_SIZE);
- side = get(args, "side", EdgeNGramTokenFilter.Side.FRONT.Label);
- if (args.Count > 0)
- {
- throw new System.ArgumentException("Unknown parameters: " + args);
- }
- }
-
- public override EdgeNGramTokenFilter create(TokenStream input)
- {
- return new EdgeNGramTokenFilter(luceneMatchVersion, input, side, minGramSize, maxGramSize);
- }
- }
+ /// <summary>
+ /// Creates a new EdgeNGramFilterFactory </summary>
+ public EdgeNGramFilterFactory(IDictionary<string, string> args)
+ : base(args)
+ {
+ minGramSize = getInt(args, "minGramSize", EdgeNGramTokenFilter.DEFAULT_MIN_GRAM_SIZE);
+ maxGramSize = getInt(args, "maxGramSize", EdgeNGramTokenFilter.DEFAULT_MAX_GRAM_SIZE);
+ side = get(args, "side", EdgeNGramTokenFilter.Side.FRONT.Label);
+ if (args.Count > 0)
+ {
+ throw new System.ArgumentException("Unknown parameters: " + args);
+ }
+ }
+ public override TokenStream Create(TokenStream input)
+ {
+ return new EdgeNGramTokenFilter(luceneMatchVersion, input, side, minGramSize, maxGramSize);
+ }
+ }
}
\ No newline at end of file