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 2015/01/30 13:39:26 UTC
[3/5] lucenenet git commit: More porting work
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/69f29113/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 d431ee7..8d0f085 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ASCIIFoldingFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/ASCIIFoldingFilterFactory.cs
@@ -4,60 +4,59 @@ using Lucene.Net.Analysis.Util;
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="ASCIIFoldingFilter"/>.
- /// <pre class="prettyprint">
- /// <fieldType name="text_ascii" class="solr.TextField" positionIncrementGap="100">
- /// <analyzer>
- /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
- /// <filter class="solr.ASCIIFoldingFilterFactory" preserveOriginal="false"/>
- /// </analyzer>
- /// </fieldType></pre>
- /// </summary>
- public class ASCIIFoldingFilterFactory : TokenFilterFactory, MultiTermAwareComponent
- {
- private readonly bool preserveOriginal;
+ /// Factory for <seealso cref="ASCIIFoldingFilter"/>.
+ /// <pre class="prettyprint">
+ /// <fieldType name="text_ascii" class="solr.TextField" positionIncrementGap="100">
+ /// <analyzer>
+ /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
+ /// <filter class="solr.ASCIIFoldingFilterFactory" preserveOriginal="false"/>
+ /// </analyzer>
+ /// </fieldType></pre>
+ /// </summary>
+ public class ASCIIFoldingFilterFactory : TokenFilterFactory, MultiTermAwareComponent
+ {
+ private readonly bool preserveOriginal;
- /// <summary>
- /// Creates a new ASCIIFoldingFilterFactory </summary>
- public ASCIIFoldingFilterFactory(IDictionary<string, string> args) : base(args)
- {
- preserveOriginal = getBoolean(args, "preserveOriginal", false);
- if (args.Count > 0)
- {
- throw new System.ArgumentException("Unknown parameters: " + args);
- }
- }
-
- public override TokenStream Create(TokenStream input)
- {
- return new ASCIIFoldingFilter(input, preserveOriginal);
- }
-
- public virtual AbstractAnalysisFactory MultiTermComponent
- {
- get
- {
- return this;
- }
- }
- }
+ /// <summary>
+ /// Creates a new ASCIIFoldingFilterFactory </summary>
+ public ASCIIFoldingFilterFactory(IDictionary<string, string> args)
+ : base(args)
+ {
+ preserveOriginal = getBoolean(args, "preserveOriginal", false);
+ if (args.Count > 0)
+ {
+ throw new System.ArgumentException("Unknown parameters: " + args);
+ }
+ }
+ public override TokenStream Create(TokenStream input)
+ {
+ return new ASCIIFoldingFilter(input, preserveOriginal);
+ }
+ public virtual AbstractAnalysisFactory MultiTermComponent
+ {
+ get
+ {
+ return this;
+ }
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/69f29113/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 9264435..e369452 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CapitalizationFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CapitalizationFilter.cs
@@ -6,198 +6,201 @@ using Lucene.Net.Analysis.Util;
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>
- /// A filter to apply normal capitalization rules to Tokens. It will make the first letter
- /// capital and the rest lower case.
- /// <p/>
- /// This filter is particularly useful to build nice looking facet parameters. This filter
- /// is not appropriate if you intend to use a prefix query.
- /// </summary>
- public sealed class CapitalizationFilter : TokenFilter
- {
- public static readonly int DEFAULT_MAX_WORD_COUNT = int.MaxValue;
- public static readonly int DEFAULT_MAX_TOKEN_LENGTH = int.MaxValue;
-
- private readonly bool onlyFirstWord;
- private readonly CharArraySet keep;
- private readonly bool forceFirstLetter;
- private readonly ICollection<char[]> okPrefix;
-
- private readonly int minWordLength;
- private readonly int maxWordCount;
- private readonly int maxTokenLength;
-
- private readonly CharTermAttribute termAtt = addAttribute(typeof(CharTermAttribute));
-
- /// <summary>
- /// Creates a CapitalizationFilter with the default parameters.
- /// <para>
- /// Calls {@link #CapitalizationFilter(TokenStream, boolean, CharArraySet, boolean, Collection, int, int, int)
- /// CapitalizationFilter(in, true, null, true, null, 0, DEFAULT_MAX_WORD_COUNT, DEFAULT_MAX_TOKEN_LENGTH)}
- /// </para>
- /// </summary>
- public CapitalizationFilter(TokenStream @in) : this(@in, true, null, true, null, 0, DEFAULT_MAX_WORD_COUNT, DEFAULT_MAX_TOKEN_LENGTH)
- {
- }
-
- /// <summary>
- /// Creates a CapitalizationFilter with the specified parameters. </summary>
- /// <param name="in"> input tokenstream </param>
- /// <param name="onlyFirstWord"> should each word be capitalized or all of the words? </param>
- /// <param name="keep"> a keep word list. Each word that should be kept separated by whitespace. </param>
- /// <param name="forceFirstLetter"> Force the first letter to be capitalized even if it is in the keep list. </param>
- /// <param name="okPrefix"> do not change word capitalization if a word begins with something in this list. </param>
- /// <param name="minWordLength"> how long the word needs to be to get capitalization applied. If the
- /// minWordLength is 3, "and" > "And" but "or" stays "or". </param>
- /// <param name="maxWordCount"> if the token contains more then maxWordCount words, the capitalization is
- /// assumed to be correct. </param>
- /// <param name="maxTokenLength"> ??? </param>
- public CapitalizationFilter(TokenStream @in, bool onlyFirstWord, CharArraySet keep, bool forceFirstLetter, ICollection<char[]> okPrefix, int minWordLength, int maxWordCount, int maxTokenLength) : base(@in)
- {
- this.onlyFirstWord = onlyFirstWord;
- this.keep = keep;
- this.forceFirstLetter = forceFirstLetter;
- this.okPrefix = okPrefix;
- this.minWordLength = minWordLength;
- this.maxWordCount = maxWordCount;
- this.maxTokenLength = maxTokenLength;
- }
-
- public override bool IncrementToken()
- {
- if (!input.IncrementToken())
- {
- return false;
- }
-
- char[] termBuffer = termAtt.Buffer();
- int termBufferLength = termAtt.Length;
- char[] backup = null;
-
- if (maxWordCount < DEFAULT_MAX_WORD_COUNT)
- {
- //make a backup in case we exceed the word count
- backup = new char[termBufferLength];
- Array.Copy(termBuffer, 0, backup, 0, termBufferLength);
- }
-
- if (termBufferLength < maxTokenLength)
- {
- int wordCount = 0;
-
- int lastWordStart = 0;
- for (int i = 0; i < termBufferLength; i++)
- {
- char c = termBuffer[i];
- if (c <= ' ' || c == '.')
- {
- int len = i - lastWordStart;
- if (len > 0)
- {
- ProcessWord(termBuffer, lastWordStart, len, wordCount++);
- lastWordStart = i + 1;
- i++;
- }
- }
- }
-
- // process the last word
- if (lastWordStart < termBufferLength)
- {
- ProcessWord(termBuffer, lastWordStart, termBufferLength - lastWordStart, wordCount++);
- }
-
- if (wordCount > maxWordCount)
- {
- termAtt.CopyBuffer(backup, 0, termBufferLength);
- }
- }
-
- return true;
- }
-
- private void ProcessWord(char[] buffer, int offset, int length, int wordCount)
- {
- if (length < 1)
- {
- return;
- }
-
- if (onlyFirstWord && wordCount > 0)
- {
- for (int i = 0; i < length; i++)
- {
- buffer[offset + i] = char.ToLower(buffer[offset + i]);
-
- }
- return;
- }
-
- if (keep != null && keep.Contains(buffer, offset, length))
- {
- if (wordCount == 0 && forceFirstLetter)
- {
- buffer[offset] = char.ToUpper(buffer[offset]);
- }
- return;
- }
-
- if (length < minWordLength)
- {
- return;
- }
-
- if (okPrefix != null)
- {
- foreach (char[] prefix in okPrefix)
- {
- if (length >= prefix.Length) //don't bother checking if the buffer length is less than the prefix
- {
- bool match = true;
- for (int i = 0; i < prefix.Length; i++)
- {
- if (prefix[i] != buffer[offset + i])
- {
- match = false;
- break;
- }
- }
- if (match == true)
- {
- return;
- }
- }
- }
- }
-
- // We know it has at least one character
- /*char[] chars = w.toCharArray();
- StringBuilder word = new StringBuilder( w.length() );
- word.append( Character.toUpperCase( chars[0] ) );*/
- buffer[offset] = char.ToUpper(buffer[offset]);
-
- for (int i = 1; i < length; i++)
- {
- buffer[offset + i] = char.ToLower(buffer[offset + i]);
- }
- //return word.toString();
- }
- }
+ /// A filter to apply normal capitalization rules to Tokens. It will make the first letter
+ /// capital and the rest lower case.
+ /// <p/>
+ /// This filter is particularly useful to build nice looking facet parameters. This filter
+ /// is not appropriate if you intend to use a prefix query.
+ /// </summary>
+ public sealed class CapitalizationFilter : TokenFilter
+ {
+ public static readonly int DEFAULT_MAX_WORD_COUNT = int.MaxValue;
+ public static readonly int DEFAULT_MAX_TOKEN_LENGTH = int.MaxValue;
+
+ private readonly bool onlyFirstWord;
+ private readonly CharArraySet keep;
+ private readonly bool forceFirstLetter;
+ private readonly ICollection<char[]> okPrefix;
+
+ private readonly int minWordLength;
+ private readonly int maxWordCount;
+ private readonly int maxTokenLength;
+
+ private readonly ICharTermAttribute termAtt;
+
+ /// <summary>
+ /// Creates a CapitalizationFilter with the default parameters.
+ /// <para>
+ /// Calls {@link #CapitalizationFilter(TokenStream, boolean, CharArraySet, boolean, Collection, int, int, int)
+ /// CapitalizationFilter(in, true, null, true, null, 0, DEFAULT_MAX_WORD_COUNT, DEFAULT_MAX_TOKEN_LENGTH)}
+ /// </para>
+ /// </summary>
+ public CapitalizationFilter(TokenStream @in)
+ : this(@in, true, null, true, null, 0, DEFAULT_MAX_WORD_COUNT, DEFAULT_MAX_TOKEN_LENGTH)
+ {
+ termAtt = AddAttribute<ICharTermAttribute>();
+ }
+
+ /// <summary>
+ /// Creates a CapitalizationFilter with the specified parameters. </summary>
+ /// <param name="in"> input tokenstream </param>
+ /// <param name="onlyFirstWord"> should each word be capitalized or all of the words? </param>
+ /// <param name="keep"> a keep word list. Each word that should be kept separated by whitespace. </param>
+ /// <param name="forceFirstLetter"> Force the first letter to be capitalized even if it is in the keep list. </param>
+ /// <param name="okPrefix"> do not change word capitalization if a word begins with something in this list. </param>
+ /// <param name="minWordLength"> how long the word needs to be to get capitalization applied. If the
+ /// minWordLength is 3, "and" > "And" but "or" stays "or". </param>
+ /// <param name="maxWordCount"> if the token contains more then maxWordCount words, the capitalization is
+ /// assumed to be correct. </param>
+ /// <param name="maxTokenLength"> ??? </param>
+ public CapitalizationFilter(TokenStream @in, bool onlyFirstWord, CharArraySet keep, bool forceFirstLetter, ICollection<char[]> okPrefix, int minWordLength, int maxWordCount, int maxTokenLength)
+ : base(@in)
+ {
+ this.onlyFirstWord = onlyFirstWord;
+ this.keep = keep;
+ this.forceFirstLetter = forceFirstLetter;
+ this.okPrefix = okPrefix;
+ this.minWordLength = minWordLength;
+ this.maxWordCount = maxWordCount;
+ this.maxTokenLength = maxTokenLength;
+ }
+
+ public override bool IncrementToken()
+ {
+ if (!input.IncrementToken())
+ {
+ return false;
+ }
+
+ char[] termBuffer = termAtt.Buffer();
+ int termBufferLength = termAtt.Length;
+ char[] backup = null;
+
+ if (maxWordCount < DEFAULT_MAX_WORD_COUNT)
+ {
+ //make a backup in case we exceed the word count
+ backup = new char[termBufferLength];
+ Array.Copy(termBuffer, 0, backup, 0, termBufferLength);
+ }
+
+ if (termBufferLength < maxTokenLength)
+ {
+ int wordCount = 0;
+
+ int lastWordStart = 0;
+ for (int i = 0; i < termBufferLength; i++)
+ {
+ char c = termBuffer[i];
+ if (c <= ' ' || c == '.')
+ {
+ int len = i - lastWordStart;
+ if (len > 0)
+ {
+ ProcessWord(termBuffer, lastWordStart, len, wordCount++);
+ lastWordStart = i + 1;
+ i++;
+ }
+ }
+ }
+
+ // process the last word
+ if (lastWordStart < termBufferLength)
+ {
+ ProcessWord(termBuffer, lastWordStart, termBufferLength - lastWordStart, wordCount++);
+ }
+
+ if (wordCount > maxWordCount)
+ {
+ termAtt.CopyBuffer(backup, 0, termBufferLength);
+ }
+ }
+
+ return true;
+ }
+
+ private void ProcessWord(char[] buffer, int offset, int length, int wordCount)
+ {
+ if (length < 1)
+ {
+ return;
+ }
+
+ if (onlyFirstWord && wordCount > 0)
+ {
+ for (int i = 0; i < length; i++)
+ {
+ buffer[offset + i] = char.ToLower(buffer[offset + i]);
+
+ }
+ return;
+ }
+
+ if (keep != null && keep.Contains(buffer, offset, length))
+ {
+ if (wordCount == 0 && forceFirstLetter)
+ {
+ buffer[offset] = char.ToUpper(buffer[offset]);
+ }
+ return;
+ }
+
+ if (length < minWordLength)
+ {
+ return;
+ }
+
+ if (okPrefix != null)
+ {
+ foreach (char[] prefix in okPrefix)
+ {
+ if (length >= prefix.Length) //don't bother checking if the buffer length is less than the prefix
+ {
+ bool match = true;
+ for (int i = 0; i < prefix.Length; i++)
+ {
+ if (prefix[i] != buffer[offset + i])
+ {
+ match = false;
+ break;
+ }
+ }
+ if (match)
+ {
+ return;
+ }
+ }
+ }
+ }
+
+ // We know it has at least one character
+ /*char[] chars = w.toCharArray();
+ StringBuilder word = new StringBuilder( w.length() );
+ word.append( Character.toUpperCase( chars[0] ) );*/
+ buffer[offset] = char.ToUpper(buffer[offset]);
+
+ for (int i = 1; i < length; i++)
+ {
+ buffer[offset + i] = char.ToLower(buffer[offset + i]);
+ }
+ //return word.toString();
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/69f29113/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 fccc4db..4bb4255 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CapitalizationFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CapitalizationFilterFactory.cs
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using Lucene.Net.Analysis.Util;
using Lucene.Net.Support;
-using org.apache.lucene.analysis.miscellaneous;
namespace Lucene.Net.Analysis.Miscellaneous
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/69f29113/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CodepointCountFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CodepointCountFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CodepointCountFilter.cs
index b410fe9..6c99fcb 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CodepointCountFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CodepointCountFilter.cs
@@ -1,82 +1,77 @@
-using FilteringTokenFilter = Lucene.Net.Analysis.Util.FilteringTokenFilter;
+using Lucene.Net.Analysis.Tokenattributes;
+using Lucene.Net.Analysis.Util;
+using Lucene.Net.Support;
+using Lucene.Net.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>
+ /// Removes words that are too long or too short from the stream.
+ /// <para>
+ /// Note: Length is calculated as the number of Unicode codepoints.
+ /// </para>
+ /// </summary>
+ public sealed class CodepointCountFilter : FilteringTokenFilter
+ {
- using FilteringTokenFilter = FilteringTokenFilter;
- using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
- using Version = org.apache.lucene.util.Version;
+ private readonly int min;
+ private readonly int max;
- /// <summary>
- /// Removes words that are too long or too short from the stream.
- /// <para>
- /// Note: Length is calculated as the number of Unicode codepoints.
- /// </para>
- /// </summary>
- public sealed class CodepointCountFilter : FilteringTokenFilter
- {
+ private readonly ICharTermAttribute termAtt;
- private readonly int min;
- private readonly int max;
-
- private readonly CharTermAttribute termAtt = addAttribute(typeof(CharTermAttribute));
-
- /// <summary>
- /// Create a new <seealso cref="CodepointCountFilter"/>. This will filter out tokens whose
- /// <seealso cref="CharTermAttribute"/> is either too short (<seealso cref="Character#codePointCount(char[], int, int)"/>
- /// < min) or too long (<seealso cref="Character#codePointCount(char[], int, int)"/> > max). </summary>
- /// <param name="version"> the Lucene match version </param>
- /// <param name="in"> the <seealso cref="TokenStream"/> to consume </param>
- /// <param name="min"> the minimum length </param>
- /// <param name="max"> the maximum length </param>
- public CodepointCountFilter(Version version, TokenStream @in, int min, int max) : base(version, @in)
- {
- this.min = min;
- this.max = max;
- }
-
- public override bool accept()
- {
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int max32 = termAtt.length();
- int max32 = termAtt.length();
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int min32 = max32 >> 1;
- int min32 = max32 >> 1;
- if (min32 >= min && max32 <= max)
- {
- // definitely within range
- return true;
- }
- else if (min32 > max || max32 < min)
- {
- // definitely not
- return false;
- }
- else
- {
- // we must count to be sure
- int len = char.codePointCount(termAtt.buffer(), 0, termAtt.length());
- return (len >= min && len <= max);
- }
- }
- }
+ /// <summary>
+ /// Create a new <seealso cref="CodepointCountFilter"/>. This will filter out tokens whose
+ /// <seealso cref="CharTermAttribute"/> is either too short (<seealso cref="Character#CodePointCount(char[], int, int)"/>
+ /// < min) or too long (<seealso cref="Character#codePointCount(char[], int, int)"/> > max). </summary>
+ /// <param name="version"> the Lucene match version </param>
+ /// <param name="in"> the <seealso cref="TokenStream"/> to consume </param>
+ /// <param name="min"> the minimum length </param>
+ /// <param name="max"> the maximum length </param>
+ public CodepointCountFilter(Version version, TokenStream @in, int min, int max)
+ : base(version, @in)
+ {
+ this.min = min;
+ this.max = max;
+ termAtt = AddAttribute<ICharTermAttribute>();
+ }
+ protected internal override bool Accept()
+ {
+ int max32 = termAtt.Length;
+ int min32 = max32 >> 1;
+ if (min32 >= min && max32 <= max)
+ {
+ // definitely within range
+ return true;
+ }
+ else if (min32 > max || max32 < min)
+ {
+ // definitely not
+ return false;
+ }
+ else
+ {
+ // we must count to be sure
+ int len = Character.CodePointCount(termAtt.Buffer(), 0, termAtt.Length);
+ return (len >= min && len <= max);
+ }
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/69f29113/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CodepointCountFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CodepointCountFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CodepointCountFilterFactory.cs
index bb37bd1..f6283bb 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CodepointCountFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/CodepointCountFilterFactory.cs
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using Lucene.Net.Analysis.Util;
-using org.apache.lucene.analysis.miscellaneous;
namespace Lucene.Net.Analysis.Miscellaneous
{
@@ -50,7 +49,7 @@ namespace Lucene.Net.Analysis.Miscellaneous
}
}
- public override CodepointCountFilter Create(TokenStream input)
+ public override TokenStream Create(TokenStream input)
{
return new CodepointCountFilter(luceneMatchVersion, input, min, max);
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/69f29113/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/HyphenatedWordsFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/HyphenatedWordsFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/HyphenatedWordsFilter.cs
index 022ee31..d423316 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/HyphenatedWordsFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/HyphenatedWordsFilter.cs
@@ -155,5 +155,4 @@ namespace Lucene.Net.Analysis.Miscellaneous
hyphenated.Length = 0;
}
}
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/69f29113/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/HyphenatedWordsFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/HyphenatedWordsFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/HyphenatedWordsFilterFactory.cs
index b274564..c281cbb 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/HyphenatedWordsFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/HyphenatedWordsFilterFactory.cs
@@ -48,5 +48,4 @@ namespace Lucene.Net.Analysis.Miscellaneous
return new HyphenatedWordsFilter(input);
}
}
-
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/69f29113/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 266f4b9..219fd2b 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeepWordFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeepWordFilterFactory.cs
@@ -1,7 +1,5 @@
using System.Collections.Generic;
using Lucene.Net.Analysis.Util;
-using org.apache.lucene.analysis.miscellaneous;
-using org.apache.lucene.analysis.util;
namespace Lucene.Net.Analysis.Miscellaneous
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/69f29113/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeywordRepeatFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeywordRepeatFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeywordRepeatFilter.cs
index f584199..ae69f03 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeywordRepeatFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeywordRepeatFilter.cs
@@ -1,75 +1,71 @@
-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 KeywordAttribute = org.apache.lucene.analysis.tokenattributes.KeywordAttribute;
- using PositionIncrementAttribute = org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
+using Lucene.Net.Analysis.Tokenattributes;
+namespace Lucene.Net.Analysis.Miscellaneous
+{
- /// <summary>
- /// This TokenFilter emits each incoming token twice once as keyword and once non-keyword, in other words once with
- /// <seealso cref="KeywordAttribute#setKeyword(boolean)"/> set to <code>true</code> and once set to <code>false</code>.
- /// This is useful if used with a stem filter that respects the <seealso cref="KeywordAttribute"/> to index the stemmed and the
- /// un-stemmed version of a term into the same field.
- /// </summary>
- public sealed class KeywordRepeatFilter : TokenFilter
- {
+ /*
+ * 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>
+ /// This TokenFilter emits each incoming token twice once as keyword and once non-keyword, in other words once with
+ /// <seealso cref="KeywordAttribute#setKeyword(boolean)"/> set to <code>true</code> and once set to <code>false</code>.
+ /// This is useful if used with a stem filter that respects the <seealso cref="KeywordAttribute"/> to index the stemmed and the
+ /// un-stemmed version of a term into the same field.
+ /// </summary>
+ public sealed class KeywordRepeatFilter : TokenFilter
+ {
- private readonly KeywordAttribute keywordAttribute = addAttribute(typeof(KeywordAttribute));
- private readonly PositionIncrementAttribute posIncAttr = addAttribute(typeof(PositionIncrementAttribute));
- private State state;
+ private readonly IKeywordAttribute keywordAttribute;
+ private readonly IPositionIncrementAttribute posIncAttr;
+ private State state;
- /// <summary>
- /// Construct a token stream filtering the given input.
- /// </summary>
- public KeywordRepeatFilter(TokenStream input) : base(input)
- {
- }
+ /// <summary>
+ /// Construct a token stream filtering the given input.
+ /// </summary>
+ public KeywordRepeatFilter(TokenStream input)
+ : base(input)
+ {
+ keywordAttribute = AddAttribute<IKeywordAttribute>();
+ posIncAttr = AddAttribute<IPositionIncrementAttribute>();
+ }
-//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()
- {
- if (state != null)
- {
- restoreState(state);
- posIncAttr.PositionIncrement = 0;
- keywordAttribute.Keyword = false;
- state = null;
- return true;
- }
- if (input.incrementToken())
- {
- state = captureState();
- keywordAttribute.Keyword = true;
- return true;
- }
- return false;
- }
+ public override bool IncrementToken()
+ {
+ if (state != null)
+ {
+ RestoreState(state);
+ posIncAttr.PositionIncrement = 0;
+ keywordAttribute.Keyword = false;
+ state = null;
+ return true;
+ }
+ if (input.IncrementToken())
+ {
+ state = CaptureState();
+ keywordAttribute.Keyword = true;
+ return true;
+ }
+ return false;
+ }
-//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();
- state = null;
- }
- }
+ public override void Reset()
+ {
+ base.Reset();
+ state = null;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/69f29113/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 1e97350..1947ca2 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeywordRepeatFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/KeywordRepeatFilterFactory.cs
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using Lucene.Net.Analysis.Util;
-using org.apache.lucene.analysis.miscellaneous;
namespace Lucene.Net.Analysis.Miscellaneous
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/69f29113/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LengthFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LengthFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LengthFilter.cs
index e0ba510..556fed2 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LengthFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LengthFilter.cs
@@ -73,7 +73,7 @@ namespace Lucene.Net.Analysis.Miscellaneous
this.max = max;
}
- public override bool Accept()
+ protected internal override bool Accept()
{
int len = termAtt.Length;
return (len >= min && len <= max);
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/69f29113/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LengthFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LengthFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LengthFilterFactory.cs
index afdc961..a5466f8 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LengthFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LengthFilterFactory.cs
@@ -1,68 +1,62 @@
using System.Collections.Generic;
-using Lucene.Net.Analysis.Miscellaneous;
-using TokenFilterFactory = Lucene.Net.Analysis.Util.TokenFilterFactory;
+using Lucene.Net.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="LengthFilter"/>.
+ /// <pre class="prettyprint">
+ /// <fieldType name="text_lngth" class="solr.TextField" positionIncrementGap="100">
+ /// <analyzer>
+ /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
+ /// <filter class="solr.LengthFilterFactory" min="0" max="1" />
+ /// </analyzer>
+ /// </fieldType></pre>
+ /// </summary>
+ public class LengthFilterFactory : TokenFilterFactory
+ {
+ internal readonly int min;
+ internal readonly int max;
+ internal readonly bool enablePositionIncrements;
+ public const string MIN_KEY = "min";
+ public const string MAX_KEY = "max";
- using TokenFilterFactory = TokenFilterFactory;
+ /// <summary>
+ /// Creates a new LengthFilterFactory </summary>
+ public LengthFilterFactory(IDictionary<string, string> args)
+ : base(args)
+ {
+ min = requireInt(args, MIN_KEY);
+ max = requireInt(args, MAX_KEY);
+ enablePositionIncrements = getBoolean(args, "enablePositionIncrements", true);
+ if (args.Count > 0)
+ {
+ throw new System.ArgumentException("Unknown parameters: " + args);
+ }
+ }
- /// <summary>
- /// Factory for <seealso cref="LengthFilter"/>.
- /// <pre class="prettyprint">
- /// <fieldType name="text_lngth" class="solr.TextField" positionIncrementGap="100">
- /// <analyzer>
- /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
- /// <filter class="solr.LengthFilterFactory" min="0" max="1" />
- /// </analyzer>
- /// </fieldType></pre>
- /// </summary>
- public class LengthFilterFactory : TokenFilterFactory
- {
- internal readonly int min;
- internal readonly int max;
- internal readonly bool enablePositionIncrements;
- public const string MIN_KEY = "min";
- public const string MAX_KEY = "max";
-
- /// <summary>
- /// Creates a new LengthFilterFactory </summary>
- public LengthFilterFactory(IDictionary<string, string> args) : base(args)
- {
- min = requireInt(args, MIN_KEY);
- max = requireInt(args, MAX_KEY);
- enablePositionIncrements = getBoolean(args, "enablePositionIncrements", true);
- if (args.Count > 0)
- {
- throw new System.ArgumentException("Unknown parameters: " + args);
- }
- }
-
- public override LengthFilter create(TokenStream input)
- {
-//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
-//ORIGINAL LINE: @SuppressWarnings("deprecation") final LengthFilter filter = new LengthFilter(luceneMatchVersion, enablePositionIncrements, input,min,max);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
- LengthFilter filter = new LengthFilter(luceneMatchVersion, enablePositionIncrements, input,min,max);
- return filter;
- }
- }
+ public override TokenStream Create(TokenStream input)
+ {
+ var filter = new LengthFilter(luceneMatchVersion, enablePositionIncrements, input, min, max);
+ return filter;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/69f29113/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenCountAnalyzer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenCountAnalyzer.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenCountAnalyzer.cs
index 58e9d60..585accd 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenCountAnalyzer.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenCountAnalyzer.cs
@@ -1,68 +1,71 @@
-namespace org.apache.lucene.analysis.miscellaneous
-{
+using 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.
- */
+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>
- /// This Analyzer limits the number of tokens while indexing. It is
- /// a replacement for the maximum field length setting inside <seealso cref="org.apache.lucene.index.IndexWriter"/>. </summary>
- /// <seealso cref= LimitTokenCountFilter </seealso>
- public sealed class LimitTokenCountAnalyzer : AnalyzerWrapper
- {
- private readonly Analyzer @delegate;
- private readonly int maxTokenCount;
- private readonly bool consumeAllTokens;
- /// <summary>
- /// Build an analyzer that limits the maximum number of tokens per field.
- /// This analyzer will not consume any tokens beyond the maxTokenCount limit
- /// </summary>
- /// <seealso cref= #LimitTokenCountAnalyzer(Analyzer,int,boolean) </seealso>
- public LimitTokenCountAnalyzer(Analyzer @delegate, int maxTokenCount) : this(@delegate, maxTokenCount, false)
- {
- }
- /// <summary>
- /// Build an analyzer that limits the maximum number of tokens per field. </summary>
- /// <param name="delegate"> the analyzer to wrap </param>
- /// <param name="maxTokenCount"> max number of tokens to produce </param>
- /// <param name="consumeAllTokens"> whether all tokens from the delegate should be consumed even if maxTokenCount is reached. </param>
- public LimitTokenCountAnalyzer(Analyzer @delegate, int maxTokenCount, bool consumeAllTokens) : base(@delegate.ReuseStrategy)
- {
- this.@delegate = @delegate;
- this.maxTokenCount = maxTokenCount;
- this.consumeAllTokens = consumeAllTokens;
- }
+ /// <summary>
+ /// This Analyzer limits the number of tokens while indexing. It is
+ /// a replacement for the maximum field length setting inside <seealso cref="org.apache.lucene.index.IndexWriter"/>. </summary>
+ /// <seealso cref= LimitTokenCountFilter </seealso>
+ public sealed class LimitTokenCountAnalyzer : AnalyzerWrapper
+ {
+ private readonly Analyzer @delegate;
+ private readonly int maxTokenCount;
+ private readonly bool consumeAllTokens;
- protected internal override Analyzer getWrappedAnalyzer(string fieldName)
- {
- return @delegate;
- }
+ /// <summary>
+ /// Build an analyzer that limits the maximum number of tokens per field.
+ /// This analyzer will not consume any tokens beyond the maxTokenCount limit
+ /// </summary>
+ /// <seealso cref= #LimitTokenCountAnalyzer(Analyzer,int,boolean) </seealso>
+ public LimitTokenCountAnalyzer(Analyzer @delegate, int maxTokenCount)
+ : this(@delegate, maxTokenCount, false)
+ {
+ }
+ /// <summary>
+ /// Build an analyzer that limits the maximum number of tokens per field. </summary>
+ /// <param name="delegate"> the analyzer to wrap </param>
+ /// <param name="maxTokenCount"> max number of tokens to produce </param>
+ /// <param name="consumeAllTokens"> whether all tokens from the delegate should be consumed even if maxTokenCount is reached. </param>
+ public LimitTokenCountAnalyzer(Analyzer @delegate, int maxTokenCount, bool consumeAllTokens)
+ : base(@delegate.ReuseStrategy)
+ {
+ this.@delegate = @delegate;
+ this.maxTokenCount = maxTokenCount;
+ this.consumeAllTokens = consumeAllTokens;
+ }
- protected internal override TokenStreamComponents wrapComponents(string fieldName, TokenStreamComponents components)
- {
- return new TokenStreamComponents(components.Tokenizer, new LimitTokenCountFilter(components.TokenStream, maxTokenCount, consumeAllTokens));
- }
+ protected override Analyzer GetWrappedAnalyzer(string fieldName)
+ {
+ return @delegate;
+ }
- public override string ToString()
- {
- return "LimitTokenCountAnalyzer(" + @delegate.ToString() + ", maxTokenCount=" + maxTokenCount + ", consumeAllTokens=" + consumeAllTokens + ")";
- }
- }
+ protected override TokenStreamComponents WrapComponents(string fieldName, TokenStreamComponents components)
+ {
+ return new TokenStreamComponents(components.Tokenizer, new LimitTokenCountFilter(components.TokenStream, maxTokenCount, consumeAllTokens));
+ }
+ public override string ToString()
+ {
+ return "LimitTokenCountAnalyzer(" + @delegate.ToString() + ", maxTokenCount=" + maxTokenCount + ", consumeAllTokens=" + consumeAllTokens + ")";
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/69f29113/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenCountFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenCountFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenCountFilter.cs
index 4b60687..18252e1 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenCountFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenCountFilter.cs
@@ -1,109 +1,107 @@
-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>
- /// This TokenFilter limits the number of tokens while indexing. It is
- /// a replacement for the maximum field length setting inside <seealso cref="org.apache.lucene.index.IndexWriter"/>.
- /// <para>
- /// By default, this filter ignores any tokens in the wrapped {@code TokenStream}
- /// once the limit has been reached, which can result in {@code reset()} being
- /// called prior to {@code incrementToken()} returning {@code false}. For most
- /// {@code TokenStream} implementations this should be acceptable, and faster
- /// then consuming the full stream. If you are wrapping a {@code TokenStream}
- /// which requires that the full stream of tokens be exhausted in order to
- /// function properly, use the
- /// <seealso cref="#LimitTokenCountFilter(TokenStream,int,boolean) consumeAllTokens"/>
- /// option.
- /// </para>
- /// </summary>
- public sealed class LimitTokenCountFilter : TokenFilter
- {
+ /// <summary>
+ /// This TokenFilter limits the number of tokens while indexing. It is
+ /// a replacement for the maximum field length setting inside <seealso cref="org.apache.lucene.index.IndexWriter"/>.
+ /// <para>
+ /// By default, this filter ignores any tokens in the wrapped {@code TokenStream}
+ /// once the limit has been reached, which can result in {@code reset()} being
+ /// called prior to {@code incrementToken()} returning {@code false}. For most
+ /// {@code TokenStream} implementations this should be acceptable, and faster
+ /// then consuming the full stream. If you are wrapping a {@code TokenStream}
+ /// which requires that the full stream of tokens be exhausted in order to
+ /// function properly, use the
+ /// <seealso cref="#LimitTokenCountFilter(TokenStream,int,boolean) consumeAllTokens"/>
+ /// option.
+ /// </para>
+ /// </summary>
+ public sealed class LimitTokenCountFilter : TokenFilter
+ {
- private readonly int maxTokenCount;
- private readonly bool consumeAllTokens;
- private int tokenCount = 0;
- private bool exhausted = false;
+ private readonly int maxTokenCount;
+ private readonly bool consumeAllTokens;
+ private int tokenCount = 0;
+ private bool exhausted = false;
- /// <summary>
- /// Build a filter that only accepts tokens up to a maximum number.
- /// This filter will not consume any tokens beyond the maxTokenCount limit
- /// </summary>
- /// <seealso cref= #LimitTokenCountFilter(TokenStream,int,boolean) </seealso>
- public LimitTokenCountFilter(TokenStream @in, int maxTokenCount) : this(@in, maxTokenCount, false)
- {
- }
+ /// <summary>
+ /// Build a filter that only accepts tokens up to a maximum number.
+ /// This filter will not consume any tokens beyond the maxTokenCount limit
+ /// </summary>
+ /// <seealso cref= #LimitTokenCountFilter(TokenStream,int,boolean) </seealso>
+ public LimitTokenCountFilter(TokenStream @in, int maxTokenCount)
+ : this(@in, maxTokenCount, false)
+ {
+ }
- /// <summary>
- /// Build an filter that limits the maximum number of tokens per field. </summary>
- /// <param name="in"> the stream to wrap </param>
- /// <param name="maxTokenCount"> max number of tokens to produce </param>
- /// <param name="consumeAllTokens"> whether all tokens from the input must be consumed even if maxTokenCount is reached. </param>
- public LimitTokenCountFilter(TokenStream @in, int maxTokenCount, bool consumeAllTokens) : base(@in)
- {
- if (maxTokenCount < 1)
- {
- throw new System.ArgumentException("maxTokenCount must be greater than zero");
- }
- this.maxTokenCount = maxTokenCount;
- this.consumeAllTokens = consumeAllTokens;
- }
+ /// <summary>
+ /// Build an filter that limits the maximum number of tokens per field. </summary>
+ /// <param name="in"> the stream to wrap </param>
+ /// <param name="maxTokenCount"> max number of tokens to produce </param>
+ /// <param name="consumeAllTokens"> whether all tokens from the input must be consumed even if maxTokenCount is reached. </param>
+ public LimitTokenCountFilter(TokenStream @in, int maxTokenCount, bool consumeAllTokens)
+ : base(@in)
+ {
+ if (maxTokenCount < 1)
+ {
+ throw new System.ArgumentException("maxTokenCount must be greater than zero");
+ }
+ this.maxTokenCount = maxTokenCount;
+ this.consumeAllTokens = consumeAllTokens;
+ }
-//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()
- {
- if (exhausted)
- {
- return false;
- }
- else if (tokenCount < maxTokenCount)
- {
- if (input.incrementToken())
- {
- tokenCount++;
- return true;
- }
- else
- {
- exhausted = true;
- return false;
- }
- }
- else
- {
- while (consumeAllTokens && input.incrementToken()) // NOOP
- {
- }
- return false;
- }
- }
+ public override bool IncrementToken()
+ {
+ if (exhausted)
+ {
+ return false;
+ }
+ else if (tokenCount < maxTokenCount)
+ {
+ if (input.IncrementToken())
+ {
+ tokenCount++;
+ return true;
+ }
+ else
+ {
+ exhausted = true;
+ return false;
+ }
+ }
+ else
+ {
+ while (consumeAllTokens && input.IncrementToken()) // NOOP
+ {
+ }
+ return false;
+ }
+ }
-//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();
- tokenCount = 0;
- exhausted = false;
- }
- }
+ public override void Reset()
+ {
+ base.Reset();
+ tokenCount = 0;
+ exhausted = false;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/69f29113/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenCountFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenCountFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenCountFilterFactory.cs
index ac55037..199b757 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenCountFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenCountFilterFactory.cs
@@ -1,67 +1,63 @@
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
{
- /*
- * 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 TokenFilterFactory = TokenFilterFactory;
-
- /// <summary>
- /// Factory for <seealso cref="LimitTokenCountFilter"/>.
- /// <pre class="prettyprint">
- /// <fieldType name="text_lngthcnt" class="solr.TextField" positionIncrementGap="100">
- /// <analyzer>
- /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
- /// <filter class="solr.LimitTokenCountFilterFactory" maxTokenCount="10" consumeAllTokens="false" />
- /// </analyzer>
- /// </fieldType></pre>
- /// <para>
- /// The {@code consumeAllTokens} property is optional and defaults to {@code false}.
- /// See <seealso cref="LimitTokenCountFilter"/> for an explanation of it's use.
- /// </para>
- /// </summary>
- public class LimitTokenCountFilterFactory : TokenFilterFactory
- {
-
- public const string MAX_TOKEN_COUNT_KEY = "maxTokenCount";
- public const string CONSUME_ALL_TOKENS_KEY = "consumeAllTokens";
- internal readonly int maxTokenCount;
- internal readonly bool consumeAllTokens;
-
- /// <summary>
- /// Creates a new LimitTokenCountFilterFactory </summary>
- public LimitTokenCountFilterFactory(IDictionary<string, string> args) : base(args)
- {
- maxTokenCount = requireInt(args, MAX_TOKEN_COUNT_KEY);
- consumeAllTokens = getBoolean(args, CONSUME_ALL_TOKENS_KEY, false);
- if (args.Count > 0)
- {
- throw new System.ArgumentException("Unknown parameters: " + args);
- }
- }
-
- public override TokenStream create(TokenStream input)
- {
- return new LimitTokenCountFilter(input, maxTokenCount, consumeAllTokens);
- }
-
- }
-
+ /*
+ * 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="LimitTokenCountFilter"/>.
+ /// <pre class="prettyprint">
+ /// <fieldType name="text_lngthcnt" class="solr.TextField" positionIncrementGap="100">
+ /// <analyzer>
+ /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
+ /// <filter class="solr.LimitTokenCountFilterFactory" maxTokenCount="10" consumeAllTokens="false" />
+ /// </analyzer>
+ /// </fieldType></pre>
+ /// <para>
+ /// The {@code consumeAllTokens} property is optional and defaults to {@code false}.
+ /// See <seealso cref="LimitTokenCountFilter"/> for an explanation of it's use.
+ /// </para>
+ /// </summary>
+ public class LimitTokenCountFilterFactory : TokenFilterFactory
+ {
+
+ public const string MAX_TOKEN_COUNT_KEY = "maxTokenCount";
+ public const string CONSUME_ALL_TOKENS_KEY = "consumeAllTokens";
+ internal readonly int maxTokenCount;
+ internal readonly bool consumeAllTokens;
+
+ /// <summary>
+ /// Creates a new LimitTokenCountFilterFactory </summary>
+ public LimitTokenCountFilterFactory(IDictionary<string, string> args)
+ : base(args)
+ {
+ maxTokenCount = requireInt(args, MAX_TOKEN_COUNT_KEY);
+ consumeAllTokens = getBoolean(args, CONSUME_ALL_TOKENS_KEY, false);
+ if (args.Count > 0)
+ {
+ throw new System.ArgumentException("Unknown parameters: " + args);
+ }
+ }
+
+ public override TokenStream Create(TokenStream input)
+ {
+ return new LimitTokenCountFilter(input, maxTokenCount, consumeAllTokens);
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/69f29113/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenPositionFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenPositionFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenPositionFilter.cs
index 931e492..6bdf9ad 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenPositionFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenPositionFilter.cs
@@ -1,116 +1,113 @@
-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 PositionIncrementAttribute = org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
+using Lucene.Net.Analysis.Tokenattributes;
- /// <summary>
- /// This TokenFilter limits its emitted tokens to those with positions that
- /// are not greater than the configured limit.
- /// <para>
- /// By default, this filter ignores any tokens in the wrapped {@code TokenStream}
- /// once the limit has been exceeded, which can result in {@code reset()} being
- /// called prior to {@code incrementToken()} returning {@code false}. For most
- /// {@code TokenStream} implementations this should be acceptable, and faster
- /// then consuming the full stream. If you are wrapping a {@code TokenStream}
- /// which requires that the full stream of tokens be exhausted in order to
- /// function properly, use the
- /// <seealso cref="#LimitTokenPositionFilter(TokenStream,int,boolean) consumeAllTokens"/>
- /// option.
- /// </para>
- /// </summary>
- public sealed class LimitTokenPositionFilter : TokenFilter
- {
-
- private readonly int maxTokenPosition;
- private readonly bool consumeAllTokens;
- private int tokenPosition = 0;
- private bool exhausted = false;
- private readonly PositionIncrementAttribute posIncAtt = addAttribute(typeof(PositionIncrementAttribute));
+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>
+ /// This TokenFilter limits its emitted tokens to those with positions that
+ /// are not greater than the configured limit.
+ /// <para>
+ /// By default, this filter ignores any tokens in the wrapped {@code TokenStream}
+ /// once the limit has been exceeded, which can result in {@code reset()} being
+ /// called prior to {@code incrementToken()} returning {@code false}. For most
+ /// {@code TokenStream} implementations this should be acceptable, and faster
+ /// then consuming the full stream. If you are wrapping a {@code TokenStream}
+ /// which requires that the full stream of tokens be exhausted in order to
+ /// function properly, use the
+ /// <seealso cref="#LimitTokenPositionFilter(TokenStream,int,boolean) consumeAllTokens"/>
+ /// option.
+ /// </para>
+ /// </summary>
+ public sealed class LimitTokenPositionFilter : TokenFilter
+ {
- /// <summary>
- /// Build a filter that only accepts tokens up to and including the given maximum position.
- /// This filter will not consume any tokens with position greater than the maxTokenPosition limit.
- /// </summary>
- /// <param name="in"> the stream to wrap </param>
- /// <param name="maxTokenPosition"> max position of tokens to produce (1st token always has position 1)
- /// </param>
- /// <seealso cref= #LimitTokenPositionFilter(TokenStream,int,boolean) </seealso>
- public LimitTokenPositionFilter(TokenStream @in, int maxTokenPosition) : this(@in, maxTokenPosition, false)
- {
- }
+ private readonly int maxTokenPosition;
+ private readonly bool consumeAllTokens;
+ private int tokenPosition = 0;
+ private bool exhausted = false;
+ private readonly IPositionIncrementAttribute posIncAtt;
- /// <summary>
- /// Build a filter that limits the maximum position of tokens to emit.
- /// </summary>
- /// <param name="in"> the stream to wrap </param>
- /// <param name="maxTokenPosition"> max position of tokens to produce (1st token always has position 1) </param>
- /// <param name="consumeAllTokens"> whether all tokens from the wrapped input stream must be consumed
- /// even if maxTokenPosition is exceeded. </param>
- public LimitTokenPositionFilter(TokenStream @in, int maxTokenPosition, bool consumeAllTokens) : base(@in)
- {
- if (maxTokenPosition < 1)
- {
- throw new System.ArgumentException("maxTokenPosition must be greater than zero");
- }
- this.maxTokenPosition = maxTokenPosition;
- this.consumeAllTokens = consumeAllTokens;
- }
+ /// <summary>
+ /// Build a filter that only accepts tokens up to and including the given maximum position.
+ /// This filter will not consume any tokens with position greater than the maxTokenPosition limit.
+ /// </summary>
+ /// <param name="in"> the stream to wrap </param>
+ /// <param name="maxTokenPosition"> max position of tokens to produce (1st token always has position 1)
+ /// </param>
+ /// <seealso cref= #LimitTokenPositionFilter(TokenStream,int,boolean) </seealso>
+ public LimitTokenPositionFilter(TokenStream @in, int maxTokenPosition)
+ : this(@in, maxTokenPosition, false)
+ {
+ posIncAtt = AddAttribute<IPositionIncrementAttribute>();
+ }
-//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()
- {
- if (exhausted)
- {
- return false;
- }
- if (input.incrementToken())
- {
- tokenPosition += posIncAtt.PositionIncrement;
- if (tokenPosition <= maxTokenPosition)
- {
- return true;
- }
- else
- {
- while (consumeAllTokens && input.incrementToken()) // NOOP
- {
- }
- exhausted = true;
- return false;
- }
- }
- else
- {
- exhausted = true;
- return false;
- }
- }
+ /// <summary>
+ /// Build a filter that limits the maximum position of tokens to emit.
+ /// </summary>
+ /// <param name="in"> the stream to wrap </param>
+ /// <param name="maxTokenPosition"> max position of tokens to produce (1st token always has position 1) </param>
+ /// <param name="consumeAllTokens"> whether all tokens from the wrapped input stream must be consumed
+ /// even if maxTokenPosition is exceeded. </param>
+ public LimitTokenPositionFilter(TokenStream @in, int maxTokenPosition, bool consumeAllTokens)
+ : base(@in)
+ {
+ if (maxTokenPosition < 1)
+ {
+ throw new System.ArgumentException("maxTokenPosition must be greater than zero");
+ }
+ this.maxTokenPosition = maxTokenPosition;
+ this.consumeAllTokens = consumeAllTokens;
+ }
-//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();
- tokenPosition = 0;
- exhausted = false;
- }
- }
+ public override bool IncrementToken()
+ {
+ if (exhausted)
+ {
+ return false;
+ }
+ if (input.IncrementToken())
+ {
+ tokenPosition += posIncAtt.PositionIncrement;
+ if (tokenPosition <= maxTokenPosition)
+ {
+ return true;
+ }
+ else
+ {
+ while (consumeAllTokens && input.IncrementToken()) // NOOP
+ {
+ }
+ exhausted = true;
+ return false;
+ }
+ }
+ else
+ {
+ exhausted = true;
+ return false;
+ }
+ }
+ public override void Reset()
+ {
+ base.Reset();
+ tokenPosition = 0;
+ exhausted = false;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/69f29113/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenPositionFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenPositionFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenPositionFilterFactory.cs
index 69877e8..44b5cfe 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenPositionFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Miscellaneous/LimitTokenPositionFilterFactory.cs
@@ -1,66 +1,62 @@
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
{
- /*
- * 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 TokenFilterFactory = TokenFilterFactory;
-
- /// <summary>
- /// Factory for <seealso cref="LimitTokenPositionFilter"/>.
- /// <pre class="prettyprint">
- /// <fieldType name="text_limit_pos" class="solr.TextField" positionIncrementGap="100">
- /// <analyzer>
- /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
- /// <filter class="solr.LimitTokenPositionFilterFactory" maxTokenPosition="3" consumeAllTokens="false" />
- /// </analyzer>
- /// </fieldType></pre>
- /// <para>
- /// The {@code consumeAllTokens} property is optional and defaults to {@code false}.
- /// See <seealso cref="LimitTokenPositionFilter"/> for an explanation of its use.
- /// </para>
- /// </summary>
- public class LimitTokenPositionFilterFactory : TokenFilterFactory
- {
-
- public const string MAX_TOKEN_POSITION_KEY = "maxTokenPosition";
- public const string CONSUME_ALL_TOKENS_KEY = "consumeAllTokens";
- internal readonly int maxTokenPosition;
- internal readonly bool consumeAllTokens;
-
- /// <summary>
- /// Creates a new LimitTokenPositionFilterFactory </summary>
- public LimitTokenPositionFilterFactory(IDictionary<string, string> args) : base(args)
- {
- maxTokenPosition = requireInt(args, MAX_TOKEN_POSITION_KEY);
- consumeAllTokens = getBoolean(args, CONSUME_ALL_TOKENS_KEY, false);
- if (args.Count > 0)
- {
- throw new System.ArgumentException("Unknown parameters: " + args);
- }
- }
-
- public override TokenStream create(TokenStream input)
- {
- return new LimitTokenPositionFilter(input, maxTokenPosition, consumeAllTokens);
- }
-
- }
-
+ /*
+ * 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="LimitTokenPositionFilter"/>.
+ /// <pre class="prettyprint">
+ /// <fieldType name="text_limit_pos" class="solr.TextField" positionIncrementGap="100">
+ /// <analyzer>
+ /// <tokenizer class="solr.WhitespaceTokenizerFactory"/>
+ /// <filter class="solr.LimitTokenPositionFilterFactory" maxTokenPosition="3" consumeAllTokens="false" />
+ /// </analyzer>
+ /// </fieldType></pre>
+ /// <para>
+ /// The {@code consumeAllTokens} property is optional and defaults to {@code false}.
+ /// See <seealso cref="LimitTokenPositionFilter"/> for an explanation of its use.
+ /// </para>
+ /// </summary>
+ public class LimitTokenPositionFilterFactory : TokenFilterFactory
+ {
+
+ public const string MAX_TOKEN_POSITION_KEY = "maxTokenPosition";
+ public const string CONSUME_ALL_TOKENS_KEY = "consumeAllTokens";
+ internal readonly int maxTokenPosition;
+ internal readonly bool consumeAllTokens;
+
+ /// <summary>
+ /// Creates a new LimitTokenPositionFilterFactory </summary>
+ public LimitTokenPositionFilterFactory(IDictionary<string, string> args)
+ : base(args)
+ {
+ maxTokenPosition = requireInt(args, MAX_TOKEN_POSITION_KEY);
+ consumeAllTokens = getBoolean(args, CONSUME_ALL_TOKENS_KEY, false);
+ if (args.Count > 0)
+ {
+ throw new System.ArgumentException("Unknown parameters: " + args);
+ }
+ }
+
+ public override TokenStream Create(TokenStream input)
+ {
+ return new LimitTokenPositionFilter(input, maxTokenPosition, consumeAllTokens);
+ }
+ }
}
\ No newline at end of file