lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [5/6] lucenenet git commit: More porting work on Analysis.Common
Date Mon, 23 Feb 2015 20:51:58 GMT
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f77e83ec/src/Lucene.Net.Analysis.Common/Analysis/Ngram/EdgeNGramTokenizer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/EdgeNGramTokenizer.cs b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/EdgeNGramTokenizer.cs
index c8d36f6..3c8dfb5 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/EdgeNGramTokenizer.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/EdgeNGramTokenizer.cs
@@ -1,71 +1,73 @@
-namespace org.apache.lucene.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.
-	 */
+using Lucene.Net.Util;
+using Reader = System.IO.TextReader;
 
-	using Version = org.apache.lucene.util.Version;
+namespace Lucene.Net.Analysis.Ngram
+{
 
-	/// <summary>
-	/// Tokenizes the input from an edge into n-grams of given size(s).
-	/// <para>
-	/// This <seealso cref="Tokenizer"/> create n-grams from the beginning edge or ending edge of a input token.
-	/// </para>
-	/// <para><a name="version" /> As of Lucene 4.4, this tokenizer<ul>
-	/// <li>can handle <code>maxGram</code> larger than 1024 chars, but beware that this will result in increased memory usage
-	/// <li>doesn't trim the input,
-	/// <li>sets position increments equal to 1 instead of 1 for the first token and 0 for all other ones
-	/// <li>doesn't support backward n-grams anymore.
-	/// <li>supports <seealso cref="#isTokenChar(int) pre-tokenization"/>,
-	/// <li>correctly handles supplementary characters.
-	/// </ul>
-	/// </para>
-	/// <para>Although <b style="color:red">highly</b> discouraged, it is still possible
-	/// to use the old behavior through <seealso cref="Lucene43EdgeNGramTokenizer"/>.
-	/// </para>
-	/// </summary>
-	public class EdgeNGramTokenizer : NGramTokenizer
-	{
-	  public const int DEFAULT_MAX_GRAM_SIZE = 1;
-	  public const int DEFAULT_MIN_GRAM_SIZE = 1;
+    /*
+     * 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>
+    /// Tokenizes the input from an edge into n-grams of given size(s).
+    /// <para>
+    /// This <seealso cref="Tokenizer"/> create n-grams from the beginning edge or ending edge of a input token.
+    /// </para>
+    /// <para><a name="version" /> As of Lucene 4.4, this tokenizer<ul>
+    /// <li>can handle <code>maxGram</code> larger than 1024 chars, but beware that this will result in increased memory usage
+    /// <li>doesn't trim the input,
+    /// <li>sets position increments equal to 1 instead of 1 for the first token and 0 for all other ones
+    /// <li>doesn't support backward n-grams anymore.
+    /// <li>supports <seealso cref="#isTokenChar(int) pre-tokenization"/>,
+    /// <li>correctly handles supplementary characters.
+    /// </ul>
+    /// </para>
+    /// <para>Although <b style="color:red">highly</b> discouraged, it is still possible
+    /// to use the old behavior through <seealso cref="Lucene43EdgeNGramTokenizer"/>.
+    /// </para>
+    /// </summary>
+    public class EdgeNGramTokenizer : NGramTokenizer
+    {
+        public const int DEFAULT_MAX_GRAM_SIZE = 1;
+        public const int DEFAULT_MIN_GRAM_SIZE = 1;
 
-	  /// <summary>
-	  /// Creates EdgeNGramTokenizer that can generate n-grams in the sizes of the given range
-	  /// </summary>
-	  /// <param name="version"> the <a href="#version">Lucene match version</a> </param>
-	  /// <param name="input"> <seealso cref="Reader"/> holding the input to be tokenized </param>
-	  /// <param name="minGram"> the smallest n-gram to generate </param>
-	  /// <param name="maxGram"> the largest n-gram to generate </param>
-	  public EdgeNGramTokenizer(Version version, Reader input, int minGram, int maxGram) : base(version, input, minGram, maxGram, true)
-	  {
-	  }
+        /// <summary>
+        /// Creates EdgeNGramTokenizer that can generate n-grams in the sizes of the given range
+        /// </summary>
+        /// <param name="version"> the <a href="#version">Lucene match version</a> </param>
+        /// <param name="input"> <seealso cref="Reader"/> holding the input to be tokenized </param>
+        /// <param name="minGram"> the smallest n-gram to generate </param>
+        /// <param name="maxGram"> the largest n-gram to generate </param>
+        public EdgeNGramTokenizer(LuceneVersion version, Reader input, int minGram, int maxGram)
+            : base(version, input, minGram, maxGram, true)
+        {
+        }
 
-	  /// <summary>
-	  /// Creates EdgeNGramTokenizer that can generate n-grams in the sizes of the given range
-	  /// </summary>
-	  /// <param name="version"> the <a href="#version">Lucene match version</a> </param>
-	  /// <param name="factory"> <seealso cref="org.apache.lucene.util.AttributeSource.AttributeFactory"/> to use </param>
-	  /// <param name="input"> <seealso cref="Reader"/> holding the input to be tokenized </param>
-	  /// <param name="minGram"> the smallest n-gram to generate </param>
-	  /// <param name="maxGram"> the largest n-gram to generate </param>
-	  public EdgeNGramTokenizer(Version version, AttributeFactory factory, Reader input, int minGram, int maxGram) : base(version, factory, input, minGram, maxGram, true)
-	  {
-	  }
+        /// <summary>
+        /// Creates EdgeNGramTokenizer that can generate n-grams in the sizes of the given range
+        /// </summary>
+        /// <param name="version"> the <a href="#version">Lucene match version</a> </param>
+        /// <param name="factory"> <seealso cref="org.apache.lucene.util.AttributeSource.AttributeFactory"/> to use </param>
+        /// <param name="input"> <seealso cref="Reader"/> holding the input to be tokenized </param>
+        /// <param name="minGram"> the smallest n-gram to generate </param>
+        /// <param name="maxGram"> the largest n-gram to generate </param>
+        public EdgeNGramTokenizer(LuceneVersion version, AttributeSource.AttributeFactory factory, Reader input, int minGram, int maxGram)
+            : base(version, factory, input, minGram, maxGram, true)
+        {
+        }
 
-	}
+    }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f77e83ec/src/Lucene.Net.Analysis.Common/Analysis/Ngram/EdgeNGramTokenizerFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/EdgeNGramTokenizerFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/EdgeNGramTokenizerFactory.cs
index 23bf8c5..cac627c 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/EdgeNGramTokenizerFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/EdgeNGramTokenizerFactory.cs
@@ -2,7 +2,6 @@
 using System.IO;
 using Lucene.Net.Analysis.Util;
 using Lucene.Net.Util;
-using org.apache.lucene.analysis.ngram;
 
 namespace Lucene.Net.Analysis.Ngram
 {
@@ -53,7 +52,7 @@ namespace Lucene.Net.Analysis.Ngram
 
 	  public override Tokenizer Create(AttributeSource.AttributeFactory factory, TextReader input)
 	  {
-		if (luceneMatchVersion.OnOrAfter(Version.LUCENE_44))
+		if (luceneMatchVersion.OnOrAfter(LuceneVersion.LUCENE_44))
 		{
 		  if (!EdgeNGramTokenFilter.Side.FRONT.Label.Equals(side))
 		  {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f77e83ec/src/Lucene.Net.Analysis.Common/Analysis/Ngram/Lucene43EdgeNGramTokenizer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/Lucene43EdgeNGramTokenizer.cs b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/Lucene43EdgeNGramTokenizer.cs
index 9809ccf..3827b36 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/Lucene43EdgeNGramTokenizer.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/Lucene43EdgeNGramTokenizer.cs
@@ -1,6 +1,9 @@
 using System;
+using Lucene.Net.Analysis.Tokenattributes;
+using Reader = System.IO.TextReader;
+using Version = Lucene.Net.Util.LuceneVersion;
 
-namespace org.apache.lucene.analysis.ngram
+namespace Lucene.Net.Analysis.Ngram
 {
 
 	/*
@@ -19,15 +22,7 @@ namespace org.apache.lucene.analysis.ngram
 	 * See the License for the specific language governing permissions and
 	 * limitations under the License.
 	 */
-
-
-	using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
-	using OffsetAttribute = org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
-	using PositionIncrementAttribute = org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
-	using ArrayUtil = org.apache.lucene.util.ArrayUtil;
-	using Version = org.apache.lucene.util.Version;
-
-	/// <summary>
+    /// <summary>
 	/// Old version of <seealso cref="EdgeNGramTokenizer"/> which doesn't handle correctly
 	/// supplementary characters.
 	/// </summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f77e83ec/src/Lucene.Net.Analysis.Common/Analysis/Ngram/Lucene43NGramTokenizer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/Lucene43NGramTokenizer.cs b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/Lucene43NGramTokenizer.cs
index b0756a6..c39c8ed 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/Lucene43NGramTokenizer.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/Lucene43NGramTokenizer.cs
@@ -1,182 +1,174 @@
 using System;
+using System.IO;
+using Lucene.Net.Analysis.Tokenattributes;
+using Reader = System.IO.TextReader;
+using Version = Lucene.Net.Util.LuceneVersion;
 
-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.
-	 */
-
-
-	using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
-	using OffsetAttribute = org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
-
-	/// <summary>
-	/// Old broken version of <seealso cref="NGramTokenizer"/>.
-	/// </summary>
-	[Obsolete]
-	public sealed class Lucene43NGramTokenizer : Tokenizer
-	{
-	  public const int DEFAULT_MIN_NGRAM_SIZE = 1;
-	  public const int DEFAULT_MAX_NGRAM_SIZE = 2;
-
-	  private int minGram, maxGram;
-	  private int gramSize;
-	  private int pos;
-	  private int inLen; // length of the input AFTER trim()
-	  private int charsRead; // length of the input
-	  private string inStr;
-	  private bool started;
-
-	  private readonly CharTermAttribute termAtt = addAttribute(typeof(CharTermAttribute));
-	  private readonly OffsetAttribute offsetAtt = addAttribute(typeof(OffsetAttribute));
-
-	  /// <summary>
-	  /// Creates NGramTokenizer with given min and max n-grams. </summary>
-	  /// <param name="input"> <seealso cref="Reader"/> holding the input to be tokenized </param>
-	  /// <param name="minGram"> the smallest n-gram to generate </param>
-	  /// <param name="maxGram"> the largest n-gram to generate </param>
-	  public Lucene43NGramTokenizer(Reader input, int minGram, int maxGram) : base(input)
-	  {
-		init(minGram, maxGram);
-	  }
-
-	  /// <summary>
-	  /// Creates NGramTokenizer with given min and max n-grams. </summary>
-	  /// <param name="factory"> <seealso cref="org.apache.lucene.util.AttributeSource.AttributeFactory"/> to use </param>
-	  /// <param name="input"> <seealso cref="Reader"/> holding the input to be tokenized </param>
-	  /// <param name="minGram"> the smallest n-gram to generate </param>
-	  /// <param name="maxGram"> the largest n-gram to generate </param>
-	  public Lucene43NGramTokenizer(AttributeFactory factory, Reader input, int minGram, int maxGram) : base(factory, input)
-	  {
-		init(minGram, maxGram);
-	  }
-
-	  /// <summary>
-	  /// Creates NGramTokenizer with default min and max n-grams. </summary>
-	  /// <param name="input"> <seealso cref="Reader"/> holding the input to be tokenized </param>
-	  public Lucene43NGramTokenizer(Reader input) : this(input, DEFAULT_MIN_NGRAM_SIZE, DEFAULT_MAX_NGRAM_SIZE)
-	  {
-	  }
-
-	  private void init(int minGram, int maxGram)
-	  {
-		if (minGram < 1)
-		{
-		  throw new System.ArgumentException("minGram must be greater than zero");
-		}
-		if (minGram > maxGram)
-		{
-		  throw new System.ArgumentException("minGram must not be greater than maxGram");
-		}
-		this.minGram = minGram;
-		this.maxGram = maxGram;
-	  }
-
-	  /// <summary>
-	  /// Returns the next token in the stream, or null at EOS. </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()
-	  {
-		clearAttributes();
-		if (!started)
-		{
-		  started = true;
-		  gramSize = minGram;
-		  char[] chars = new char[1024];
-		  charsRead = 0;
-		  // TODO: refactor to a shared readFully somewhere:
-		  while (charsRead < chars.Length)
-		  {
-			int inc = input.read(chars, charsRead, chars.Length - charsRead);
-			if (inc == -1)
-			{
-			  break;
-			}
-			charsRead += inc;
-		  }
-		  inStr = (new string(chars, 0, charsRead)).Trim(); // remove any trailing empty strings
-
-		  if (charsRead == chars.Length)
-		  {
-			// Read extra throwaway chars so that on end() we
-			// report the correct offset:
-			char[] throwaway = new char[1024];
-			while (true)
-			{
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int inc = input.read(throwaway, 0, throwaway.length);
-			  int inc = input.read(throwaway, 0, throwaway.Length);
-			  if (inc == -1)
-			  {
-				break;
-			  }
-			  charsRead += inc;
-			}
-		  }
-
-		  inLen = inStr.Length;
-		  if (inLen == 0)
-		  {
-			return false;
-		  }
-		}
-
-		if (pos + gramSize > inLen) // if we hit the end of the string
-		{
-		  pos = 0; // reset to beginning of string
-		  gramSize++; // increase n-gram size
-		  if (gramSize > maxGram) // we are done
-		  {
-			return false;
-		  }
-		  if (pos + gramSize > inLen)
-		  {
-			return false;
-		  }
-		}
-
-		int oldPos = pos;
-		pos++;
-		termAtt.setEmpty().append(inStr, oldPos, oldPos + gramSize);
-		offsetAtt.setOffset(correctOffset(oldPos), correctOffset(oldPos + gramSize));
-		return true;
-	  }
-
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public void end() throws java.io.IOException
-	  public override void end()
-	  {
-		base.end();
-		// set final offset
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int finalOffset = correctOffset(charsRead);
-		int finalOffset = correctOffset(charsRead);
-		this.offsetAtt.setOffset(finalOffset, finalOffset);
-	  }
-
-//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();
-		started = false;
-		pos = 0;
-	  }
-	}
+    /*
+     * 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>
+    /// Old broken version of <seealso cref="NGramTokenizer"/>.
+    /// </summary>
+    [Obsolete]
+    public sealed class Lucene43NGramTokenizer : Tokenizer
+    {
+        public const int DEFAULT_MIN_NGRAM_SIZE = 1;
+        public const int DEFAULT_MAX_NGRAM_SIZE = 2;
+
+        private int minGram, maxGram;
+        private int gramSize;
+        private int pos;
+        private int inLen; // length of the input AFTER trim()
+        private int charsRead; // length of the input
+        private string inStr;
+        private bool started;
+
+        private readonly CharTermAttribute termAtt = addAttribute(typeof(CharTermAttribute));
+        private readonly OffsetAttribute offsetAtt = addAttribute(typeof(OffsetAttribute));
+
+        /// <summary>
+        /// Creates NGramTokenizer with given min and max n-grams. </summary>
+        /// <param name="input"> <seealso cref="TextReader"/> holding the input to be tokenized </param>
+        /// <param name="minGram"> the smallest n-gram to generate </param>
+        /// <param name="maxGram"> the largest n-gram to generate </param>
+        public Lucene43NGramTokenizer(TextReader input, int minGram, int maxGram)
+            : base(input)
+        {
+            init(minGram, maxGram);
+        }
+
+        /// <summary>
+        /// Creates NGramTokenizer with given min and max n-grams. </summary>
+        /// <param name="factory"> <seealso cref="org.apache.lucene.util.AttributeSource.AttributeFactory"/> to use </param>
+        /// <param name="input"> <seealso cref="Reader"/> holding the input to be tokenized </param>
+        /// <param name="minGram"> the smallest n-gram to generate </param>
+        /// <param name="maxGram"> the largest n-gram to generate </param>
+        public Lucene43NGramTokenizer(AttributeFactory factory, TextReader input, int minGram, int maxGram)
+            : base(factory, input)
+        {
+            init(minGram, maxGram);
+        }
+
+        /// <summary>
+        /// Creates NGramTokenizer with default min and max n-grams. </summary>
+        /// <param name="input"> <seealso cref="TextReader"/> holding the input to be tokenized </param>
+        public Lucene43NGramTokenizer(TextReader input)
+            : this(input, DEFAULT_MIN_NGRAM_SIZE, DEFAULT_MAX_NGRAM_SIZE)
+        {
+        }
+
+        private void init(int minGram, int maxGram)
+        {
+            if (minGram < 1)
+            {
+                throw new System.ArgumentException("minGram must be greater than zero");
+            }
+            if (minGram > maxGram)
+            {
+                throw new System.ArgumentException("minGram must not be greater than maxGram");
+            }
+            this.minGram = minGram;
+            this.maxGram = maxGram;
+        }
+
+        /// <summary>
+        /// Returns the next token in the stream, or null at EOS. </summary>
+        public override bool IncrementToken()
+        {
+            ClearAttributes();
+            if (!started)
+            {
+                started = true;
+                gramSize = minGram;
+                char[] chars = new char[1024];
+                charsRead = 0;
+                // TODO: refactor to a shared readFully somewhere:
+                while (charsRead < chars.Length)
+                {
+                    int inc = input.Read(chars, charsRead, chars.Length - charsRead);
+                    if (inc == -1)
+                    {
+                        break;
+                    }
+                    charsRead += inc;
+                }
+                inStr = (new string(chars, 0, charsRead)).Trim(); // remove any trailing empty strings
+
+                if (charsRead == chars.Length)
+                {
+                    // Read extra throwaway chars so that on end() we
+                    // report the correct offset:
+                    var throwaway = new char[1024];
+                    while (true)
+                    {
+                        int inc = input.Read(throwaway, 0, throwaway.Length);
+                        if (inc == -1)
+                        {
+                            break;
+                        }
+                        charsRead += inc;
+                    }
+                }
+
+                inLen = inStr.Length;
+                if (inLen == 0)
+                {
+                    return false;
+                }
+            }
+
+            if (pos + gramSize > inLen) // if we hit the end of the string
+            {
+                pos = 0; // reset to beginning of string
+                gramSize++; // increase n-gram size
+                if (gramSize > maxGram) // we are done
+                {
+                    return false;
+                }
+                if (pos + gramSize > inLen)
+                {
+                    return false;
+                }
+            }
+
+            int oldPos = pos;
+            pos++;
+            termAtt.SetEmpty().Append(inStr, oldPos, oldPos + gramSize);
+            offsetAtt.SetOffset(CorrectOffset(oldPos), CorrectOffset(oldPos + gramSize));
+            return true;
+        }
+
+        public override void End()
+        {
+            base.End();
+            // set final offset
+            int finalOffset = CorrectOffset(charsRead);
+            this.offsetAtt.SetOffset(finalOffset, finalOffset);
+        }
+
+        public override void Reset()
+        {
+            base.Reset();
+            started = false;
+            pos = 0;
+        }
+    }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f77e83ec/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramFilterFactory.cs
index 132f3bd..fb286f5 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramFilterFactory.cs
@@ -1,59 +1,59 @@
 using System.Collections.Generic;
-using TokenFilterFactory = Lucene.Net.Analysis.Util.TokenFilterFactory;
+using Lucene.Net.Analysis.Util;
+using Reader = System.IO.TextReader;
+using Version = Lucene.Net.Util.LuceneVersion;
 
-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>
+    /// Factory for <seealso cref="NGramTokenFilter"/>.
+    /// <pre class="prettyprint">
+    /// &lt;fieldType name="text_ngrm" class="solr.TextField" positionIncrementGap="100"&gt;
+    ///   &lt;analyzer&gt;
+    ///     &lt;tokenizer class="solr.WhitespaceTokenizerFactory"/&gt;
+    ///     &lt;filter class="solr.NGramFilterFactory" minGramSize="1" maxGramSize="2"/&gt;
+    ///   &lt;/analyzer&gt;
+    /// &lt;/fieldType&gt;</pre>
+    /// </summary>
+    public class NGramFilterFactory : TokenFilterFactory
+    {
+        private readonly int maxGramSize;
+        private readonly int minGramSize;
 
-	using TokenFilterFactory = TokenFilterFactory;
+        /// <summary>
+        /// Creates a new NGramFilterFactory </summary>
+        public NGramFilterFactory(IDictionary<string, string> args)
+            : base(args)
+        {
+            minGramSize = getInt(args, "minGramSize", NGramTokenFilter.DEFAULT_MIN_NGRAM_SIZE);
+            maxGramSize = getInt(args, "maxGramSize", NGramTokenFilter.DEFAULT_MAX_NGRAM_SIZE);
+            if (args.Count > 0)
+            {
+                throw new System.ArgumentException("Unknown parameters: " + args);
+            }
+        }
 
-	/// <summary>
-	/// Factory for <seealso cref="NGramTokenFilter"/>.
-	/// <pre class="prettyprint">
-	/// &lt;fieldType name="text_ngrm" class="solr.TextField" positionIncrementGap="100"&gt;
-	///   &lt;analyzer&gt;
-	///     &lt;tokenizer class="solr.WhitespaceTokenizerFactory"/&gt;
-	///     &lt;filter class="solr.NGramFilterFactory" minGramSize="1" maxGramSize="2"/&gt;
-	///   &lt;/analyzer&gt;
-	/// &lt;/fieldType&gt;</pre>
-	/// </summary>
-	public class NGramFilterFactory : TokenFilterFactory
-	{
-	  private readonly int maxGramSize;
-	  private readonly int minGramSize;
-
-	  /// <summary>
-	  /// Creates a new NGramFilterFactory </summary>
-	  public NGramFilterFactory(IDictionary<string, string> args) : base(args)
-	  {
-		minGramSize = getInt(args, "minGramSize", NGramTokenFilter.DEFAULT_MIN_NGRAM_SIZE);
-		maxGramSize = getInt(args, "maxGramSize", NGramTokenFilter.DEFAULT_MAX_NGRAM_SIZE);
-		if (args.Count > 0)
-		{
-		  throw new System.ArgumentException("Unknown parameters: " + args);
-		}
-	  }
-
-	  public override NGramTokenFilter create(TokenStream input)
-	  {
-		return new NGramTokenFilter(luceneMatchVersion, input, minGramSize, maxGramSize);
-	  }
-	}
+        public override TokenStream Create(TokenStream input)
+        {
+            return new NGramTokenFilter(luceneMatchVersion, input, minGramSize, maxGramSize);
+        }
+    }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f77e83ec/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramTokenFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramTokenFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramTokenFilter.cs
index 85b997e..f9d08cd 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramTokenFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramTokenFilter.cs
@@ -1,254 +1,244 @@
 using Lucene.Net.Analysis.Miscellaneous;
+using Lucene.Net.Analysis.Tokenattributes;
 using Lucene.Net.Analysis.Util;
+using Lucene.Net.Util;
+using Reader = System.IO.TextReader;
+using Version = Lucene.Net.Util.LuceneVersion;
 
-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.
-	 */
-
-	using CodepointCountFilter = CodepointCountFilter;
-	using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
-	using OffsetAttribute = org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
-	using PositionIncrementAttribute = org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
-	using PositionLengthAttribute = org.apache.lucene.analysis.tokenattributes.PositionLengthAttribute;
-	using CharacterUtils = CharacterUtils;
-	using Version = org.apache.lucene.util.Version;
-
-	/// <summary>
-	/// Tokenizes the input into n-grams of the given size(s).
-	/// <a name="version"/>
-	/// <para>You must specify the required <seealso cref="Version"/> compatibility when
-	/// creating a <seealso cref="NGramTokenFilter"/>. As of Lucene 4.4, this token filters:<ul>
-	/// <li>handles supplementary characters correctly,</li>
-	/// <li>emits all n-grams for the same token at the same position,</li>
-	/// <li>does not modify offsets,</li>
-	/// <li>sorts n-grams by their offset in the original token first, then
-	/// increasing length (meaning that "abc" will give "a", "ab", "abc", "b", "bc",
-	/// "c").</li></ul>
-	/// </para>
-	/// <para>You can make this filter use the old behavior by providing a version &lt;
-	/// <seealso cref="Version#LUCENE_44"/> in the constructor but this is not recommended as
-	/// it will lead to broken <seealso cref="TokenStream"/>s that will cause highlighting
-	/// bugs.
-	/// </para>
-	/// <para>If you were using this <seealso cref="TokenFilter"/> to perform partial highlighting,
-	/// this won't work anymore since this filter doesn't update offsets. You should
-	/// modify your analysis chain to use <seealso cref="NGramTokenizer"/>, and potentially
-	/// override <seealso cref="NGramTokenizer#isTokenChar(int)"/> to perform pre-tokenization.
-	/// </para>
-	/// </summary>
-	public sealed class NGramTokenFilter : TokenFilter
-	{
-	  public const int DEFAULT_MIN_NGRAM_SIZE = 1;
-	  public const int DEFAULT_MAX_NGRAM_SIZE = 2;
-
-	  private readonly int minGram, maxGram;
-
-	  private char[] curTermBuffer;
-	  private int curTermLength;
-	  private int curCodePointCount;
-	  private int curGramSize;
-	  private int curPos;
-	  private int curPosInc, curPosLen;
-	  private int tokStart;
-	  private int tokEnd;
-	  private bool hasIllegalOffsets; // only if the length changed before this filter
-
-	  private readonly Version version;
-	  private readonly CharacterUtils charUtils;
-	  private readonly CharTermAttribute termAtt = addAttribute(typeof(CharTermAttribute));
-	  private readonly PositionIncrementAttribute posIncAtt;
-	  private readonly PositionLengthAttribute posLenAtt;
-	  private readonly OffsetAttribute offsetAtt = addAttribute(typeof(OffsetAttribute));
-
-	  /// <summary>
-	  /// Creates NGramTokenFilter with given min and max n-grams. </summary>
-	  /// <param name="version"> Lucene version to enable correct position increments.
-	  ///                See <a href="#version">above</a> for details. </param>
-	  /// <param name="input"> <seealso cref="TokenStream"/> holding the input to be tokenized </param>
-	  /// <param name="minGram"> the smallest n-gram to generate </param>
-	  /// <param name="maxGram"> the largest n-gram to generate </param>
-	  public NGramTokenFilter(Version version, TokenStream input, int minGram, int maxGram) : base(new CodepointCountFilter(version, input, minGram, int.MaxValue))
-	  {
-		this.version = version;
-		this.charUtils = version.onOrAfter(Version.LUCENE_44) ? CharacterUtils.getInstance(version) : CharacterUtils.Java4Instance;
-		if (minGram < 1)
-		{
-		  throw new System.ArgumentException("minGram must be greater than zero");
-		}
-		if (minGram > maxGram)
-		{
-		  throw new System.ArgumentException("minGram must not be greater than maxGram");
-		}
-		this.minGram = minGram;
-		this.maxGram = maxGram;
-		if (version.onOrAfter(Version.LUCENE_44))
-		{
-		  posIncAtt = addAttribute(typeof(PositionIncrementAttribute));
-		  posLenAtt = addAttribute(typeof(PositionLengthAttribute));
-		}
-		else
-		{
-		  posIncAtt = new PositionIncrementAttributeAnonymousInnerClassHelper(this);
-		  posLenAtt = new PositionLengthAttributeAnonymousInnerClassHelper(this);
-		}
-	  }
-
-	  private class PositionIncrementAttributeAnonymousInnerClassHelper : PositionIncrementAttribute
-	  {
-		  private readonly NGramTokenFilter outerInstance;
-
-		  public PositionIncrementAttributeAnonymousInnerClassHelper(NGramTokenFilter outerInstance)
-		  {
-			  this.outerInstance = outerInstance;
-		  }
-
-		  public override int PositionIncrement
-		  {
-			  set
-			  {
-			  }
-			  get
-			  {
-				return 0;
-			  }
-		  }
-	  }
-
-	  private class PositionLengthAttributeAnonymousInnerClassHelper : PositionLengthAttribute
-	  {
-		  private readonly NGramTokenFilter outerInstance;
-
-		  public PositionLengthAttributeAnonymousInnerClassHelper(NGramTokenFilter outerInstance)
-		  {
-			  this.outerInstance = outerInstance;
-		  }
-
-		  public override int PositionLength
-		  {
-			  set
-			  {
-			  }
-			  get
-			  {
-				return 0;
-			  }
-		  }
-	  }
-
-	  /// <summary>
-	  /// Creates NGramTokenFilter with default min and max n-grams. </summary>
-	  /// <param name="version"> Lucene version to enable correct position increments.
-	  ///                See <a href="#version">above</a> for details. </param>
-	  /// <param name="input"> <seealso cref="TokenStream"/> holding the input to be tokenized </param>
-	  public NGramTokenFilter(Version version, TokenStream input) : this(version, input, DEFAULT_MIN_NGRAM_SIZE, DEFAULT_MAX_NGRAM_SIZE)
-	  {
-	  }
-
-	  /// <summary>
-	  /// Returns the next token in the stream, or null at EOS. </summary>
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public final boolean incrementToken() throws java.io.IOException
-	  public override bool incrementToken()
-	  {
-		while (true)
-		{
-		  if (curTermBuffer == null)
-		  {
-			if (!input.incrementToken())
-			{
-			  return false;
-			}
-			else
-			{
-			  curTermBuffer = termAtt.buffer().clone();
-			  curTermLength = termAtt.length();
-			  curCodePointCount = charUtils.codePointCount(termAtt);
-			  curGramSize = minGram;
-			  curPos = 0;
-			  curPosInc = posIncAtt.PositionIncrement;
-			  curPosLen = posLenAtt.PositionLength;
-			  tokStart = offsetAtt.startOffset();
-			  tokEnd = offsetAtt.endOffset();
-			  // if length by start + end offsets doesn't match the term text then assume
-			  // this is a synonym and don't adjust the offsets.
-			  hasIllegalOffsets = (tokStart + curTermLength) != tokEnd;
-			}
-		  }
-		  if (version.onOrAfter(Version.LUCENE_44))
-		  {
-			if (curGramSize > maxGram || (curPos + curGramSize) > curCodePointCount)
-			{
-			  ++curPos;
-			  curGramSize = minGram;
-			}
-			if ((curPos + curGramSize) <= curCodePointCount)
-			{
-			  clearAttributes();
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int start = charUtils.offsetByCodePoints(curTermBuffer, 0, curTermLength, 0, curPos);
-			  int start = charUtils.offsetByCodePoints(curTermBuffer, 0, curTermLength, 0, curPos);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int end = charUtils.offsetByCodePoints(curTermBuffer, 0, curTermLength, start, curGramSize);
-			  int end = charUtils.offsetByCodePoints(curTermBuffer, 0, curTermLength, start, curGramSize);
-			  termAtt.copyBuffer(curTermBuffer, start, end - start);
-			  posIncAtt.PositionIncrement = curPosInc;
-			  curPosInc = 0;
-			  posLenAtt.PositionLength = curPosLen;
-			  offsetAtt.setOffset(tokStart, tokEnd);
-			  curGramSize++;
-			  return true;
-			}
-		  }
-		  else
-		  {
-			while (curGramSize <= maxGram)
-			{
-			  while (curPos + curGramSize <= curTermLength) // while there is input
-			  {
-				clearAttributes();
-				termAtt.copyBuffer(curTermBuffer, curPos, curGramSize);
-				if (hasIllegalOffsets)
-				{
-				  offsetAtt.setOffset(tokStart, tokEnd);
-				}
-				else
-				{
-				  offsetAtt.setOffset(tokStart + curPos, tokStart + curPos + curGramSize);
-				}
-				curPos++;
-				return true;
-			  }
-			  curGramSize++; // increase n-gram size
-			  curPos = 0;
-			}
-		  }
-		  curTermBuffer = null;
-		}
-	  }
-
-//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();
-		curTermBuffer = null;
-	  }
-	}
+    /*
+     * 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>
+    /// Tokenizes the input into n-grams of the given size(s).
+    /// <a name="version"/>
+    /// <para>You must specify the required <seealso cref="Version"/> compatibility when
+    /// creating a <seealso cref="NGramTokenFilter"/>. As of Lucene 4.4, this token filters:<ul>
+    /// <li>handles supplementary characters correctly,</li>
+    /// <li>emits all n-grams for the same token at the same position,</li>
+    /// <li>does not modify offsets,</li>
+    /// <li>sorts n-grams by their offset in the original token first, then
+    /// increasing length (meaning that "abc" will give "a", "ab", "abc", "b", "bc",
+    /// "c").</li></ul>
+    /// </para>
+    /// <para>You can make this filter use the old behavior by providing a version &lt;
+    /// <seealso cref="Version#LUCENE_44"/> in the constructor but this is not recommended as
+    /// it will lead to broken <seealso cref="TokenStream"/>s that will cause highlighting
+    /// bugs.
+    /// </para>
+    /// <para>If you were using this <seealso cref="TokenFilter"/> to perform partial highlighting,
+    /// this won't work anymore since this filter doesn't update offsets. You should
+    /// modify your analysis chain to use <seealso cref="NGramTokenizer"/>, and potentially
+    /// override <seealso cref="NGramTokenizer#isTokenChar(int)"/> to perform pre-tokenization.
+    /// </para>
+    /// </summary>
+    public sealed class NGramTokenFilter : TokenFilter
+    {
+        public const int DEFAULT_MIN_NGRAM_SIZE = 1;
+        public const int DEFAULT_MAX_NGRAM_SIZE = 2;
+
+        private readonly int minGram, maxGram;
+
+        private char[] curTermBuffer;
+        private int curTermLength;
+        private int curCodePointCount;
+        private int curGramSize;
+        private int curPos;
+        private int curPosInc, curPosLen;
+        private int tokStart;
+        private int tokEnd;
+        private bool hasIllegalOffsets; // only if the length changed before this filter
+
+        private readonly Version version;
+        private readonly CharacterUtils charUtils;
+        private readonly CharTermAttribute termAtt = addAttribute(typeof(CharTermAttribute));
+        private readonly PositionIncrementAttribute posIncAtt;
+        private readonly PositionLengthAttribute posLenAtt;
+        private readonly OffsetAttribute offsetAtt = addAttribute(typeof(OffsetAttribute));
+
+        /// <summary>
+        /// Creates NGramTokenFilter with given min and max n-grams. </summary>
+        /// <param name="version"> Lucene version to enable correct position increments.
+        ///                See <a href="#version">above</a> for details. </param>
+        /// <param name="input"> <seealso cref="TokenStream"/> holding the input to be tokenized </param>
+        /// <param name="minGram"> the smallest n-gram to generate </param>
+        /// <param name="maxGram"> the largest n-gram to generate </param>
+        public NGramTokenFilter(Version version, TokenStream input, int minGram, int maxGram)
+            : base(new CodepointCountFilter(version, input, minGram, int.MaxValue))
+        {
+            this.version = version;
+            this.charUtils = version.OnOrAfter(Version.LUCENE_44) ? CharacterUtils.GetInstance(version) : CharacterUtils.Java4Instance;
+            if (minGram < 1)
+            {
+                throw new System.ArgumentException("minGram must be greater than zero");
+            }
+            if (minGram > maxGram)
+            {
+                throw new System.ArgumentException("minGram must not be greater than maxGram");
+            }
+            this.minGram = minGram;
+            this.maxGram = maxGram;
+            if (version.OnOrAfter(Version.LUCENE_44))
+            {
+                posIncAtt = AddAttribute(typeof(PositionIncrementAttribute));
+                posLenAtt = AddAttribute(typeof(PositionLengthAttribute));
+            }
+            else
+            {
+                posIncAtt = new PositionIncrementAttributeAnonymousInnerClassHelper(this);
+                posLenAtt = new PositionLengthAttributeAnonymousInnerClassHelper(this);
+            }
+        }
+
+        private class PositionIncrementAttributeAnonymousInnerClassHelper : PositionIncrementAttribute
+        {
+            private readonly NGramTokenFilter outerInstance;
+
+            public PositionIncrementAttributeAnonymousInnerClassHelper(NGramTokenFilter outerInstance)
+            {
+                this.outerInstance = outerInstance;
+            }
+
+            public override int PositionIncrement
+            {
+                set
+                {
+                }
+                get
+                {
+                    return 0;
+                }
+            }
+        }
+
+        private class PositionLengthAttributeAnonymousInnerClassHelper : PositionLengthAttribute
+        {
+            private readonly NGramTokenFilter outerInstance;
+
+            public PositionLengthAttributeAnonymousInnerClassHelper(NGramTokenFilter outerInstance)
+            {
+                this.outerInstance = outerInstance;
+            }
+
+            public override int PositionLength
+            {
+                set
+                {
+                }
+                get
+                {
+                    return 0;
+                }
+            }
+        }
+
+        /// <summary>
+        /// Creates NGramTokenFilter with default min and max n-grams. </summary>
+        /// <param name="version"> Lucene version to enable correct position increments.
+        ///                See <a href="#version">above</a> for details. </param>
+        /// <param name="input"> <seealso cref="TokenStream"/> holding the input to be tokenized </param>
+        public NGramTokenFilter(Version version, TokenStream input)
+            : this(version, input, DEFAULT_MIN_NGRAM_SIZE, DEFAULT_MAX_NGRAM_SIZE)
+        {
+        }
+
+        /// <summary>
+        /// Returns the next token in the stream, or null at EOS.
+        /// </summary>
+        public override bool IncrementToken()
+        {
+            while (true)
+            {
+                if (curTermBuffer == null)
+                {
+                    if (!input.IncrementToken())
+                    {
+                        return false;
+                    }
+                    else
+                    {
+                        curTermBuffer = termAtt.Buffer().Clone();
+                        curTermLength = termAtt.Length;
+                        curCodePointCount = charUtils.CodePointCount(termAtt);
+                        curGramSize = minGram;
+                        curPos = 0;
+                        curPosInc = posIncAtt.PositionIncrement;
+                        curPosLen = posLenAtt.PositionLength;
+                        tokStart = offsetAtt.StartOffset();
+                        tokEnd = offsetAtt.EndOffset();
+                        // if length by start + end offsets doesn't match the term text then assume
+                        // this is a synonym and don't adjust the offsets.
+                        hasIllegalOffsets = (tokStart + curTermLength) != tokEnd;
+                    }
+                }
+                if (version.OnOrAfter(Version.LUCENE_44))
+                {
+                    if (curGramSize > maxGram || (curPos + curGramSize) > curCodePointCount)
+                    {
+                        ++curPos;
+                        curGramSize = minGram;
+                    }
+                    if ((curPos + curGramSize) <= curCodePointCount)
+                    {
+                        ClearAttributes();
+                        int start = charUtils.OffsetByCodePoints(curTermBuffer, 0, curTermLength, 0, curPos);
+                        int end = charUtils.OffsetByCodePoints(curTermBuffer, 0, curTermLength, start, curGramSize);
+                        termAtt.CopyBuffer(curTermBuffer, start, end - start);
+                        posIncAtt.PositionIncrement = curPosInc;
+                        curPosInc = 0;
+                        posLenAtt.PositionLength = curPosLen;
+                        offsetAtt.SetOffset(tokStart, tokEnd);
+                        curGramSize++;
+                        return true;
+                    }
+                }
+                else
+                {
+                    while (curGramSize <= maxGram)
+                    {
+                        while (curPos + curGramSize <= curTermLength) // while there is input
+                        {
+                            ClearAttributes();
+                            termAtt.CopyBuffer(curTermBuffer, curPos, curGramSize);
+                            if (hasIllegalOffsets)
+                            {
+                                offsetAtt.SetOffset(tokStart, tokEnd);
+                            }
+                            else
+                            {
+                                offsetAtt.SetOffset(tokStart + curPos, tokStart + curPos + curGramSize);
+                            }
+                            curPos++;
+                            return true;
+                        }
+                        curGramSize++; // increase n-gram size
+                        curPos = 0;
+                    }
+                }
+                curTermBuffer = null;
+            }
+        }
+
+        public override void Reset()
+        {
+            base.Reset();
+            curTermBuffer = null;
+        }
+    }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f77e83ec/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramTokenizer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramTokenizer.cs b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramTokenizer.cs
index 37d6102..984c684 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramTokenizer.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramTokenizer.cs
@@ -1,8 +1,14 @@
 using System;
 using System.Diagnostics;
+using System.IO;
+using Lucene.Net.Analysis.Tokenattributes;
 using Lucene.Net.Analysis.Util;
+using Lucene.Net.Support;
+using Lucene.Net.Util;
+using Reader = System.IO.TextReader;
+using Version = Lucene.Net.Util.LuceneVersion;
 
-namespace org.apache.lucene.analysis.ngram
+namespace Lucene.Net.Analysis.Ngram
 {
 
 	/*
@@ -21,16 +27,7 @@ namespace org.apache.lucene.analysis.ngram
 	 * See the License for the specific language governing permissions and
 	 * limitations under the License.
 	 */
-
-
-	using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
-	using OffsetAttribute = org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
-	using PositionIncrementAttribute = org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
-	using PositionLengthAttribute = org.apache.lucene.analysis.tokenattributes.PositionLengthAttribute;
-	using CharacterUtils = CharacterUtils;
-	using Version = org.apache.lucene.util.Version;
-
-	/// <summary>
+    /// <summary>
 	/// Tokenizes the input into n-grams of the given size(s).
 	/// <para>On the contrary to <seealso cref="NGramTokenFilter"/>, this class sets offsets so
 	/// that characters between startOffset and endOffset in the original stream are
@@ -85,7 +82,7 @@ namespace org.apache.lucene.analysis.ngram
 	  private readonly PositionLengthAttribute posLenAtt = addAttribute(typeof(PositionLengthAttribute));
 	  private readonly OffsetAttribute offsetAtt = addAttribute(typeof(OffsetAttribute));
 
-	  internal NGramTokenizer(Version version, Reader input, int minGram, int maxGram, bool edgesOnly) : base(input)
+	  internal NGramTokenizer(LuceneVersion version, TextReader input, int minGram, int maxGram, bool edgesOnly) : base(input)
 	  {
 		init(version, minGram, maxGram, edgesOnly);
 	  }
@@ -93,14 +90,14 @@ namespace org.apache.lucene.analysis.ngram
 	  /// <summary>
 	  /// Creates NGramTokenizer with given min and max n-grams. </summary>
 	  /// <param name="version"> the lucene compatibility <a href="#version">version</a> </param>
-	  /// <param name="input"> <seealso cref="Reader"/> holding the input to be tokenized </param>
+	  /// <param name="input"> <seealso cref="TextReader"/> holding the input to be tokenized </param>
 	  /// <param name="minGram"> the smallest n-gram to generate </param>
 	  /// <param name="maxGram"> the largest n-gram to generate </param>
-	  public NGramTokenizer(Version version, Reader input, int minGram, int maxGram) : this(version, input, minGram, maxGram, false)
+	  public NGramTokenizer(LuceneVersion version, TextReader input, int minGram, int maxGram) : this(version, input, minGram, maxGram, false)
 	  {
 	  }
 
-	  internal NGramTokenizer(Version version, AttributeFactory factory, Reader input, int minGram, int maxGram, bool edgesOnly) : base(factory, input)
+	  internal NGramTokenizer(LuceneVersion version, AttributeFactory factory, TextReader input, int minGram, int maxGram, bool edgesOnly) : base(factory, input)
 	  {
 		init(version, minGram, maxGram, edgesOnly);
 	  }
@@ -112,25 +109,25 @@ namespace org.apache.lucene.analysis.ngram
 	  /// <param name="input"> <seealso cref="Reader"/> holding the input to be tokenized </param>
 	  /// <param name="minGram"> the smallest n-gram to generate </param>
 	  /// <param name="maxGram"> the largest n-gram to generate </param>
-	  public NGramTokenizer(Version version, AttributeFactory factory, Reader input, int minGram, int maxGram) : this(version, factory, input, minGram, maxGram, false)
+	  public NGramTokenizer(LuceneVersion version, AttributeFactory factory, TextReader input, int minGram, int maxGram) : this(version, factory, input, minGram, maxGram, false)
 	  {
 	  }
 
 	  /// <summary>
 	  /// Creates NGramTokenizer with default min and max n-grams. </summary>
 	  /// <param name="version"> the lucene compatibility <a href="#version">version</a> </param>
-	  /// <param name="input"> <seealso cref="Reader"/> holding the input to be tokenized </param>
-	  public NGramTokenizer(Version version, Reader input) : this(version, input, DEFAULT_MIN_NGRAM_SIZE, DEFAULT_MAX_NGRAM_SIZE)
+	  /// <param name="input"> <seealso cref="TextReader"/> holding the input to be tokenized </param>
+	  public NGramTokenizer(LuceneVersion version, TextReader input) : this(version, input, DEFAULT_MIN_NGRAM_SIZE, DEFAULT_MAX_NGRAM_SIZE)
 	  {
 	  }
 
-	  private void init(Version version, int minGram, int maxGram, bool edgesOnly)
+	  private void init(LuceneVersion version, int minGram, int maxGram, bool edgesOnly)
 	  {
-		if (!version.onOrAfter(Version.LUCENE_44))
+		if (!version.OnOrAfter(LuceneVersion.LUCENE_44))
 		{
 		  throw new System.ArgumentException("This class only works with Lucene 4.4+. To emulate the old (broken) behavior of NGramTokenizer, use Lucene43NGramTokenizer/Lucene43EdgeNGramTokenizer");
 		}
-		charUtils = version.onOrAfter(Version.LUCENE_44) ? CharacterUtils.getInstance(version) : CharacterUtils.Java4Instance;
+		charUtils = version.OnOrAfter(LuceneVersion.LUCENE_44) ? CharacterUtils.GetInstance(version) : CharacterUtils.Java4Instance;
 		if (minGram < 1)
 		{
 		  throw new System.ArgumentException("minGram must be greater than zero");
@@ -142,17 +139,15 @@ namespace org.apache.lucene.analysis.ngram
 		this.minGram = minGram;
 		this.maxGram = maxGram;
 		this.edgesOnly = edgesOnly;
-		charBuffer = CharacterUtils.newCharacterBuffer(2 * maxGram + 1024); // 2 * maxGram in case all code points require 2 chars and + 1024 for buffering to not keep polling the Reader
+		charBuffer = CharacterUtils.NewCharacterBuffer(2 * maxGram + 1024); // 2 * maxGram in case all code points require 2 chars and + 1024 for buffering to not keep polling the Reader
 		buffer = new int[charBuffer.Buffer.Length];
 		// Make the term att large enough
-		termAtt.resizeBuffer(2 * maxGram);
+		termAtt.ResizeBuffer(2 * maxGram);
 	  }
 
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public final boolean incrementToken() throws java.io.IOException
-	  public override bool incrementToken()
+	  public override bool IncrementToken()
 	  {
-		clearAttributes();
+		ClearAttributes();
 
 		// termination of this loop is guaranteed by the fact that every iteration
 		// either advances the buffer (calls consumes()) or increases gramSize
@@ -168,7 +163,7 @@ namespace org.apache.lucene.analysis.ngram
 			bufferStart = 0;
 
 			// fill in remaining space
-			exhausted = !charUtils.fill(charBuffer, input, buffer.Length - bufferEnd);
+			exhausted = !charUtils.Fill(charBuffer, input, buffer.Length - bufferEnd);
 			// convert to code points
 			bufferEnd += charUtils.toCodePoints(charBuffer.Buffer, 0, charBuffer.Length, buffer, bufferEnd);
 		  }
@@ -188,11 +183,7 @@ namespace org.apache.lucene.analysis.ngram
 		  updateLastNonTokenChar();
 
 		  // retry if the token to be emitted was going to not only contain token chars
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final boolean termContainsNonTokenChar = lastNonTokenChar >= bufferStart && lastNonTokenChar < (bufferStart + gramSize);
 		  bool termContainsNonTokenChar = lastNonTokenChar >= bufferStart && lastNonTokenChar < (bufferStart + gramSize);
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final boolean isEdgeAndPreviousCharIsTokenChar = edgesOnly && lastNonTokenChar != bufferStart - 1;
 		  bool isEdgeAndPreviousCharIsTokenChar = edgesOnly && lastNonTokenChar != bufferStart - 1;
 		  if (termContainsNonTokenChar || isEdgeAndPreviousCharIsTokenChar)
 		  {
@@ -201,13 +192,11 @@ namespace org.apache.lucene.analysis.ngram
 			continue;
 		  }
 
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int length = charUtils.toChars(buffer, bufferStart, gramSize, termAtt.buffer(), 0);
-		  int length = charUtils.toChars(buffer, bufferStart, gramSize, termAtt.buffer(), 0);
+		  int length = charUtils.toChars(buffer, bufferStart, gramSize, termAtt.Buffer(), 0);
 		  termAtt.Length = length;
 		  posIncAtt.PositionIncrement = 1;
 		  posLenAtt.PositionLength = 1;
-		  offsetAtt.setOffset(correctOffset(offset), correctOffset(offset + length));
+		  offsetAtt.SetOffset(CorrectOffset(offset), CorrectOffset(offset + length));
 		  ++gramSize;
 		  return true;
 		}
@@ -215,14 +204,12 @@ namespace org.apache.lucene.analysis.ngram
 
 	  private void updateLastNonTokenChar()
 	  {
-//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
-//ORIGINAL LINE: final int termEnd = bufferStart + gramSize - 1;
 		int termEnd = bufferStart + gramSize - 1;
 		if (termEnd > lastCheckedChar)
 		{
 		  for (int i = termEnd; i > lastCheckedChar; --i)
 		  {
-			if (!isTokenChar(buffer[i]))
+			if (!IsTokenChar(buffer[i]))
 			{
 			  lastNonTokenChar = i;
 			  break;
@@ -236,37 +223,33 @@ namespace org.apache.lucene.analysis.ngram
 	  /// Consume one code point. </summary>
 	  private void consume()
 	  {
-		offset += char.charCount(buffer[bufferStart++]);
+		offset += Character.CharCount(buffer[bufferStart++]);
 	  }
 
 	  /// <summary>
 	  /// Only collect characters which satisfy this condition. </summary>
-	  protected internal virtual bool isTokenChar(int chr)
+	  protected internal virtual bool IsTokenChar(int chr)
 	  {
 		return true;
 	  }
 
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public final void end() throws java.io.IOException
-	  public override void end()
+	  public override void End()
 	  {
-		base.end();
+		base.End();
 		Debug.Assert(bufferStart <= bufferEnd);
 		int endOffset = offset;
 		for (int i = bufferStart; i < bufferEnd; ++i)
 		{
-		  endOffset += char.charCount(buffer[i]);
+		  endOffset += Character.CharCount(buffer[i]);
 		}
-		endOffset = correctOffset(endOffset);
+		endOffset = CorrectOffset(endOffset);
 		// set final offset
-		offsetAtt.setOffset(endOffset, endOffset);
+		offsetAtt.SetOffset(endOffset, endOffset);
 	  }
 
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: @Override public final void reset() throws java.io.IOException
-	  public override void reset()
+	  public override void Reset()
 	  {
-		base.reset();
+		base.Reset();
 		bufferStart = bufferEnd = buffer.Length;
 		lastNonTokenChar = lastCheckedChar = bufferStart - 1;
 		offset = 0;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f77e83ec/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramTokenizerFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramTokenizerFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramTokenizerFactory.cs
index d90b0ad..07e7f15 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramTokenizerFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Ngram/NGramTokenizerFactory.cs
@@ -1,70 +1,68 @@
 using System.Collections.Generic;
-using TokenizerFactory = Lucene.Net.Analysis.Util.TokenizerFactory;
+using Lucene.Net.Analysis.Util;
+using Lucene.Net.Util;
+using Reader = System.IO.TextReader;
+using Version = Lucene.Net.Util.LuceneVersion;
 
-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>
+    /// Factory for <seealso cref="NGramTokenizer"/>.
+    /// <pre class="prettyprint">
+    /// &lt;fieldType name="text_ngrm" class="solr.TextField" positionIncrementGap="100"&gt;
+    ///   &lt;analyzer&gt;
+    ///     &lt;tokenizer class="solr.NGramTokenizerFactory" minGramSize="1" maxGramSize="2"/&gt;
+    ///   &lt;/analyzer&gt;
+    /// &lt;/fieldType&gt;</pre>
+    /// </summary>
+    public class NGramTokenizerFactory : TokenizerFactory
+    {
+        private readonly int maxGramSize;
+        private readonly int minGramSize;
 
-	using TokenizerFactory = TokenizerFactory;
-	using AttributeFactory = org.apache.lucene.util.AttributeSource.AttributeFactory;
-	using Version = org.apache.lucene.util.Version;
+        /// <summary>
+        /// Creates a new NGramTokenizerFactory </summary>
+        public NGramTokenizerFactory(IDictionary<string, string> args)
+            : base(args)
+        {
+            minGramSize = getInt(args, "minGramSize", NGramTokenizer.DEFAULT_MIN_NGRAM_SIZE);
+            maxGramSize = getInt(args, "maxGramSize", NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE);
+            if (args.Count > 0)
+            {
+                throw new System.ArgumentException("Unknown parameters: " + args);
+            }
+        }
 
-
-	/// <summary>
-	/// Factory for <seealso cref="NGramTokenizer"/>.
-	/// <pre class="prettyprint">
-	/// &lt;fieldType name="text_ngrm" class="solr.TextField" positionIncrementGap="100"&gt;
-	///   &lt;analyzer&gt;
-	///     &lt;tokenizer class="solr.NGramTokenizerFactory" minGramSize="1" maxGramSize="2"/&gt;
-	///   &lt;/analyzer&gt;
-	/// &lt;/fieldType&gt;</pre>
-	/// </summary>
-	public class NGramTokenizerFactory : TokenizerFactory
-	{
-	  private readonly int maxGramSize;
-	  private readonly int minGramSize;
-
-	  /// <summary>
-	  /// Creates a new NGramTokenizerFactory </summary>
-	  public NGramTokenizerFactory(IDictionary<string, string> args) : base(args)
-	  {
-		minGramSize = getInt(args, "minGramSize", NGramTokenizer.DEFAULT_MIN_NGRAM_SIZE);
-		maxGramSize = getInt(args, "maxGramSize", NGramTokenizer.DEFAULT_MAX_NGRAM_SIZE);
-		if (args.Count > 0)
-		{
-		  throw new System.ArgumentException("Unknown parameters: " + args);
-		}
-	  }
-
-	  /// <summary>
-	  /// Creates the <seealso cref="TokenStream"/> of n-grams from the given <seealso cref="Reader"/> and <seealso cref="AttributeFactory"/>. </summary>
-	  public override Tokenizer create(AttributeFactory factory, Reader input)
-	  {
-		if (luceneMatchVersion.onOrAfter(Version.LUCENE_44))
-		{
-		  return new NGramTokenizer(luceneMatchVersion, factory, input, minGramSize, maxGramSize);
-		}
-		else
-		{
-		  return new Lucene43NGramTokenizer(factory, input, minGramSize, maxGramSize);
-		}
-	  }
-	}
+        /// <summary>
+        /// Creates the <seealso cref="TokenStream"/> of n-grams from the given <seealso cref="Reader"/> and <seealso cref="AttributeSource.AttributeFactory"/>. </summary>
+        public override Tokenizer Create(AttributeSource.AttributeFactory factory, Reader input)
+        {
+            if (luceneMatchVersion.OnOrAfter(Version.LUCENE_44))
+            {
+                return new NGramTokenizer(luceneMatchVersion, factory, input, minGramSize, maxGramSize);
+            }
+            else
+            {
+                return new Lucene43NGramTokenizer(factory, input, minGramSize, maxGramSize);
+            }
+        }
+    }
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f77e83ec/src/Lucene.Net.Analysis.Common/Analysis/Position/PositionFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Position/PositionFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Position/PositionFilterFactory.cs
index 476c7fe..3a71808 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Position/PositionFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Position/PositionFilterFactory.cs
@@ -50,7 +50,7 @@ namespace Lucene.Net.Analysis.Position
             {
                 throw new System.ArgumentException("Unknown parameters: " + args);
             }
-            if (luceneMatchVersion != null && luceneMatchVersion.OnOrAfter(Lucene.Net.Util.Version.LUCENE_44))
+            if (luceneMatchVersion != null && luceneMatchVersion.OnOrAfter(Lucene.Net.Util.LuceneVersion.LUCENE_44))
             {
                 throw new System.ArgumentException("PositionFilter is deprecated as of Lucene 4.4. You should either fix your code to not use it or use Lucene 4.3 version compatibility");
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f77e83ec/src/Lucene.Net.Analysis.Common/Analysis/Query/QueryAutoStopWordAnalyzer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Query/QueryAutoStopWordAnalyzer.cs b/src/Lucene.Net.Analysis.Common/Analysis/Query/QueryAutoStopWordAnalyzer.cs
index 548b7f6..7d839a9 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Query/QueryAutoStopWordAnalyzer.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Query/QueryAutoStopWordAnalyzer.cs
@@ -42,7 +42,7 @@ namespace Lucene.Net.Analysis.Query
         //The default maximum percentage (40%) of index documents which
         //can contain a term, after which the term is considered to be a stop word.
         public const float defaultMaxDocFreqPercent = 0.4f;
-        private readonly Version matchVersion;
+        private readonly LuceneVersion matchVersion;
 
         /// <summary>
         /// Creates a new QueryAutoStopWordAnalyzer with stopwords calculated for all
@@ -53,7 +53,7 @@ namespace Lucene.Net.Analysis.Query
         /// <param name="delegate"> Analyzer whose TokenStream will be filtered </param>
         /// <param name="indexReader"> IndexReader to identify the stopwords from </param>
         /// <exception cref="IOException"> Can be thrown while reading from the IndexReader </exception>
-        public QueryAutoStopWordAnalyzer(Version matchVersion, Analyzer @delegate, IndexReader indexReader)
+        public QueryAutoStopWordAnalyzer(LuceneVersion matchVersion, Analyzer @delegate, IndexReader indexReader)
             : this(matchVersion, @delegate, indexReader, defaultMaxDocFreqPercent)
         {
         }
@@ -68,7 +68,7 @@ namespace Lucene.Net.Analysis.Query
         /// <param name="indexReader"> IndexReader to identify the stopwords from </param>
         /// <param name="maxDocFreq"> Document frequency terms should be above in order to be stopwords </param>
         /// <exception cref="IOException"> Can be thrown while reading from the IndexReader </exception>
-        public QueryAutoStopWordAnalyzer(Version matchVersion, Analyzer @delegate, IndexReader indexReader, int maxDocFreq)
+        public QueryAutoStopWordAnalyzer(LuceneVersion matchVersion, Analyzer @delegate, IndexReader indexReader, int maxDocFreq)
             : this(matchVersion, @delegate, indexReader, MultiFields.GetIndexedFields(indexReader), maxDocFreq)
         {
         }
@@ -84,7 +84,7 @@ namespace Lucene.Net.Analysis.Query
         /// <param name="maxPercentDocs"> The maximum percentage (between 0.0 and 1.0) of index documents which
         ///                      contain a term, after which the word is considered to be a stop word </param>
         /// <exception cref="IOException"> Can be thrown while reading from the IndexReader </exception>
-        public QueryAutoStopWordAnalyzer(Version matchVersion, Analyzer @delegate, IndexReader indexReader, float maxPercentDocs)
+        public QueryAutoStopWordAnalyzer(LuceneVersion matchVersion, Analyzer @delegate, IndexReader indexReader, float maxPercentDocs)
             : this(matchVersion, @delegate, indexReader, MultiFields.GetIndexedFields(indexReader), maxPercentDocs)
         {
         }
@@ -101,7 +101,7 @@ namespace Lucene.Net.Analysis.Query
         /// <param name="maxPercentDocs"> The maximum percentage (between 0.0 and 1.0) of index documents which
         ///                      contain a term, after which the word is considered to be a stop word </param>
         /// <exception cref="IOException"> Can be thrown while reading from the IndexReader </exception>
-        public QueryAutoStopWordAnalyzer(Version matchVersion, Analyzer @delegate, IndexReader indexReader, ICollection<string> fields, float maxPercentDocs)
+        public QueryAutoStopWordAnalyzer(LuceneVersion matchVersion, Analyzer @delegate, IndexReader indexReader, ICollection<string> fields, float maxPercentDocs)
             : this(matchVersion, @delegate, indexReader, fields, (int)(indexReader.NumDocs * maxPercentDocs))
         {
         }
@@ -117,7 +117,7 @@ namespace Lucene.Net.Analysis.Query
         /// <param name="fields"> Selection of fields to calculate stopwords for </param>
         /// <param name="maxDocFreq"> Document frequency terms should be above in order to be stopwords </param>
         /// <exception cref="IOException"> Can be thrown while reading from the IndexReader </exception>
-        public QueryAutoStopWordAnalyzer(Version matchVersion, Analyzer @delegate, IndexReader indexReader, ICollection<string> fields, int maxDocFreq)
+        public QueryAutoStopWordAnalyzer(LuceneVersion matchVersion, Analyzer @delegate, IndexReader indexReader, ICollection<string> fields, int maxDocFreq)
             : base(@delegate.Strategy)
         {
             this.matchVersion = matchVersion;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f77e83ec/src/Lucene.Net.Analysis.Common/Analysis/Shingle/ShingleAnalyzerWrapper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Shingle/ShingleAnalyzerWrapper.cs b/src/Lucene.Net.Analysis.Common/Analysis/Shingle/ShingleAnalyzerWrapper.cs
index b7d1f5d..9c5d109 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Shingle/ShingleAnalyzerWrapper.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Shingle/ShingleAnalyzerWrapper.cs
@@ -96,14 +96,14 @@ namespace Lucene.Net.Analysis.Shingle
 	  /// <summary>
 	  /// Wraps <seealso cref="StandardAnalyzer"/>. 
 	  /// </summary>
-	  public ShingleAnalyzerWrapper(Version matchVersion) : this(matchVersion, ShingleFilter.DEFAULT_MIN_SHINGLE_SIZE, ShingleFilter.DEFAULT_MAX_SHINGLE_SIZE)
+	  public ShingleAnalyzerWrapper(LuceneVersion matchVersion) : this(matchVersion, ShingleFilter.DEFAULT_MIN_SHINGLE_SIZE, ShingleFilter.DEFAULT_MAX_SHINGLE_SIZE)
 	  {
 	  }
 
 	  /// <summary>
 	  /// Wraps <seealso cref="StandardAnalyzer"/>. 
 	  /// </summary>
-	  public ShingleAnalyzerWrapper(Version matchVersion, int minShingleSize, int maxShingleSize) : this(new StandardAnalyzer(matchVersion), minShingleSize, maxShingleSize)
+	  public ShingleAnalyzerWrapper(LuceneVersion matchVersion, int minShingleSize, int maxShingleSize) : this(new StandardAnalyzer(matchVersion), minShingleSize, maxShingleSize)
 	  {
 	  }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f77e83ec/src/Lucene.Net.Analysis.Common/Analysis/Standard/StandardAnalyzer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Standard/StandardAnalyzer.cs b/src/Lucene.Net.Analysis.Common/Analysis/Standard/StandardAnalyzer.cs
index 5458b33..ecb534f 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Standard/StandardAnalyzer.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Standard/StandardAnalyzer.cs
@@ -29,7 +29,7 @@ namespace Lucene.Net.Analysis.Standard
 	/// English stop words.
 	/// 
 	/// <a name="version"/>
-	/// <para>You must specify the required <seealso cref="Version"/>
+	/// <para>You must specify the required <seealso cref="LuceneVersion"/>
 	/// compatibility when creating StandardAnalyzer:
 	/// <ul>
 	///   <li> As of 3.4, Hiragana and Han characters are no longer wrongly split
@@ -66,7 +66,7 @@ namespace Lucene.Net.Analysis.Standard
 	  /// <param name="matchVersion"> Lucene version to match See {@link
 	  /// <a href="#version">above</a>} </param>
 	  /// <param name="stopWords"> stop words  </param>
-	  public StandardAnalyzer(Version matchVersion, CharArraySet stopWords) : base(matchVersion, stopWords)
+	  public StandardAnalyzer(LuceneVersion matchVersion, CharArraySet stopWords) : base(matchVersion, stopWords)
 	  {
 	  }
 
@@ -75,7 +75,7 @@ namespace Lucene.Net.Analysis.Standard
 	  /// #STOP_WORDS_SET}). </summary>
 	  /// <param name="matchVersion"> Lucene version to match See {@link
 	  /// <a href="#version">above</a>} </param>
-	  public StandardAnalyzer(Version matchVersion) : this(matchVersion, STOP_WORDS_SET)
+	  public StandardAnalyzer(LuceneVersion matchVersion) : this(matchVersion, STOP_WORDS_SET)
 	  {
 	  }
 
@@ -85,7 +85,7 @@ namespace Lucene.Net.Analysis.Standard
 	  /// <param name="matchVersion"> Lucene version to match See {@link
 	  /// <a href="#version">above</a>} </param>
 	  /// <param name="stopwords"> Reader to read stop words from  </param>
-	  public StandardAnalyzer(Version matchVersion, TextReader stopwords) : this(matchVersion, loadStopwordSet(stopwords, matchVersion))
+	  public StandardAnalyzer(LuceneVersion matchVersion, TextReader stopwords) : this(matchVersion, loadStopwordSet(stopwords, matchVersion))
 	  {
 	  }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f77e83ec/src/Lucene.Net.Analysis.Common/Analysis/Synonym/FSTSynonymFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Synonym/FSTSynonymFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Synonym/FSTSynonymFilterFactory.cs
index f28fd11..651477a 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Synonym/FSTSynonymFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Synonym/FSTSynonymFilterFactory.cs
@@ -6,8 +6,6 @@ using System.Text.RegularExpressions;
 using Lucene.Net.Analysis.Core;
 using Lucene.Net.Analysis.Util;
 using Lucene.Net.Util;
-using org.apache.lucene.analysis.synonym;
-using Version = Lucene.Net.Util.Version;
 
 namespace Lucene.Net.Analysis.Synonym
 {
@@ -113,8 +111,8 @@ namespace Lucene.Net.Analysis.Synonym
 
             public override TokenStreamComponents CreateComponents(string fieldName, TextReader reader)
             {
-                Tokenizer tokenizer = factory == null ? new WhitespaceTokenizer(Version.LUCENE_CURRENT, reader) : factory.Create(reader);
-                TokenStream stream = outerInstance.ignoreCase ? new LowerCaseFilter(Version.LUCENE_CURRENT, tokenizer) : tokenizer;
+                Tokenizer tokenizer = factory == null ? new WhitespaceTokenizer(LuceneVersion.LUCENE_CURRENT, reader) : factory.Create(reader);
+                TokenStream stream = outerInstance.ignoreCase ? new LowerCaseFilter(LuceneVersion.LUCENE_CURRENT, tokenizer) : tokenizer;
                 return new Analyzer.TokenStreamComponents(tokenizer, stream);
             }
         }
@@ -140,7 +138,7 @@ namespace Lucene.Net.Analysis.Synonym
             if (File.Exists(synonyms))
             {
                 decoder.Reset();
-                parser.parse(new InputStreamReader(loader.openResource(synonyms), decoder));
+                parser.Parse(new InputStreamReader(loader.openResource(synonyms), decoder));
             }
             else
             {
@@ -148,10 +146,10 @@ namespace Lucene.Net.Analysis.Synonym
                 foreach (string file in files)
                 {
                     decoder.reset();
-                    parser.parse(new InputStreamReader(loader.openResource(file), decoder));
+                    parser.Parse(new InputStreamReader(loader.openResource(file), decoder));
                 }
             }
-            return parser.build();
+            return parser.Build();
         }
 
         // (there are no tests for this functionality)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f77e83ec/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SlowSynonymFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SlowSynonymFilter.cs b/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SlowSynonymFilter.cs
index 95b3c1f..511f333 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SlowSynonymFilter.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SlowSynonymFilter.cs
@@ -34,7 +34,7 @@ namespace Lucene.Net.Analysis.Synonym
 	/// </para>
 	/// </summary>
 	/// @deprecated (3.4) use <seealso cref="SynonymFilterFactory"/> instead. only for precise index backwards compatibility. this factory will be removed in Lucene 5.0 
-	[Obsolete("(3.4) use <seealso cref="SynonymFilterFactory"/> instead. only for precise index backwards compatibility. this factory will be removed in Lucene 5.0")]
+	[Obsolete("(3.4) use <seealso cref=\"SynonymFilterFactory\"/> instead. only for precise index backwards compatibility. this factory will be removed in Lucene 5.0")]
 	internal sealed class SlowSynonymFilter : TokenFilter
 	{
 
@@ -45,15 +45,15 @@ namespace Lucene.Net.Analysis.Synonym
 	  {
 		if (map == null)
 		{
-		  throw new System.ArgumentException("map is required");
+		  throw new System.ArgumentException("map is required", "map");
 		}
 
 		this.map = map;
 		// just ensuring these attributes exist...
-		AddAttribute(typeof(CharTermAttribute));
-		AddAttribute(typeof(PositionIncrementAttribute));
-		AddAttribute(typeof(OffsetAttribute));
-		AddAttribute(typeof(TypeAttribute));
+	      AddAttribute<ICharTermAttribute>();
+          AddAttribute < IPositionIncrementAttribute>();
+          AddAttribute < IOffsetAttribute>();
+          AddAttribute < TypeAttribute>();
 	  }
 
 
@@ -74,19 +74,15 @@ namespace Lucene.Net.Analysis.Synonym
 	   *    merging token streams to preserve token positions.
 	   *  - preserve original positionIncrement of first matched token
 	   */
-//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()
 	  {
 		while (true)
 		{
 		  // if there are any generated tokens, return them... don't try any
 		  // matches against them, as we specifically don't want recursion.
-//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
-		  if (replacement != null && replacement.hasNext())
+		  if (replacement != null && replacement.MoveNext())
 		  {
-//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
-			copy(this, replacement.next());
+			copy(this, replacement.Current);
 			return true;
 		  }
 
@@ -96,8 +92,8 @@ namespace Lucene.Net.Analysis.Synonym
 		  {
 			  return false;
 		  }
-		  CharTermAttribute termAtt = firstTok.addAttribute(typeof(CharTermAttribute));
-		  SlowSynonymMap result = map.submap != null ? map.submap.get(termAtt.buffer(), 0, termAtt.length()) : null;
+		  var termAtt = firstTok.AddAttribute<ICharTermAttribute>();
+		  SlowSynonymMap result = map.submap != null ? map.submap.Get(termAtt.Buffer(), 0, termAtt.Length) : null;
 		  if (result == null)
 		  {
 			copy(this, firstTok);
@@ -107,7 +103,7 @@ namespace Lucene.Net.Analysis.Synonym
 		  // fast-path failed, clone ourselves if needed
 		  if (firstTok == this)
 		  {
-			firstTok = cloneAttributes();
+			firstTok = CloneAttributes();
 		  }
 		  // OK, we matched a token, so find the longest match.
 
@@ -130,7 +126,7 @@ namespace Lucene.Net.Analysis.Synonym
 		  // in the matched tokens (position increments need adjusting)
 		  //
 		  AttributeSource lastTok = matched.Count == 0 ? firstTok : matched.Last.Value;
-		  bool includeOrig = result.includeOrig();
+		  bool includeOrig = result.IncludeOrig;
 
 		  AttributeSource origTok = includeOrig ? firstTok : null;
 		  PositionIncrementAttribute firstPosIncAtt = firstTok.addAttribute(typeof(PositionIncrementAttribute));
@@ -243,8 +239,6 @@ namespace Lucene.Net.Analysis.Synonym
 		buffer.AddFirst(t);
 	  }
 
-//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
-//ORIGINAL LINE: private SlowSynonymMap match(SlowSynonymMap map) throws java.io.IOException
 	  private SlowSynonymMap match(SlowSynonymMap map)
 	  {
 		SlowSynonymMap result = null;
@@ -257,11 +251,11 @@ namespace Lucene.Net.Analysis.Synonym
 			// clone ourselves.
 			if (tok == this)
 			{
-			  tok = cloneAttributes();
+			  tok = CloneAttributes();
 			}
 			// check for positionIncrement!=1?  if>1, should not match, if==0, check multiple at this level?
-			CharTermAttribute termAtt = tok.getAttribute(typeof(CharTermAttribute));
-			SlowSynonymMap subMap = map.submap.get(termAtt.buffer(), 0, termAtt.length());
+            var termAtt = tok.GetAttribute < ICharTermAttribute>();
+			SlowSynonymMap subMap = map.submap.Get(termAtt.buffer(), 0, termAtt.length());
 
 			if (subMap != null)
 			{

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f77e83ec/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SlowSynonymFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SlowSynonymFilterFactory.cs b/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SlowSynonymFilterFactory.cs
index 1f3d604..17e2035 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SlowSynonymFilterFactory.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SlowSynonymFilterFactory.cs
@@ -2,10 +2,9 @@
 using System.Collections;
 using System.Collections.Generic;
 using System.Text;
-using Lucene.Net.Analysis.Synonym;
 using Lucene.Net.Analysis.Util;
 
-namespace org.apache.lucene.analysis.synonym
+namespace Lucene.Net.Analysis.Synonym
 {
 
 	/*
@@ -24,12 +23,7 @@ namespace org.apache.lucene.analysis.synonym
 	 * See the License for the specific language governing permissions and
 	 * limitations under the License.
 	 */
-
-	using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
-	using org.apache.lucene.analysis.util;
-
-
-	/// <summary>
+    /// <summary>
 	/// Factory for <seealso cref="SlowSynonymFilter"/> (only used with luceneMatchVersion < 3.4)
 	/// <pre class="prettyprint" >
 	/// &lt;fieldType name="text_synonym" class="solr.TextField" positionIncrementGap="100"&gt;
@@ -40,7 +34,7 @@ namespace org.apache.lucene.analysis.synonym
 	///   &lt;/analyzer&gt;
 	/// &lt;/fieldType&gt;</pre> </summary>
 	/// @deprecated (3.4) use <seealso cref="SynonymFilterFactory"/> instead. only for precise index backwards compatibility. this factory will be removed in Lucene 5.0 
-	[Obsolete("(3.4) use <seealso cref="SynonymFilterFactory"/> instead. only for precise index backwards compatibility. this factory will be removed in Lucene 5.0")]
+	[Obsolete("(3.4) use <seealso cref=\"SynonymFilterFactory\"/> instead. only for precise index backwards compatibility. this factory will be removed in Lucene 5.0")]
 	internal sealed class SlowSynonymFilterFactory : TokenFilterFactory, ResourceLoaderAware
 	{
 	  private readonly string synonyms;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/f77e83ec/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SlowSynonymMap.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SlowSynonymMap.cs b/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SlowSynonymMap.cs
index 3129a83..d1fb0a4 100644
--- a/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SlowSynonymMap.cs
+++ b/src/Lucene.Net.Analysis.Common/Analysis/Synonym/SlowSynonymMap.cs
@@ -51,13 +51,24 @@ namespace Lucene.Net.Analysis.Synonym
             }
         }
 
-        public virtual bool IncludeOrig()
+        public virtual bool IncludeOrig
         {
-            return (flags & INCLUDE_ORIG) != 0;
+            get
+            {
+                {
+                    return (flags & INCLUDE_ORIG) != 0;
+                }
+            }
         }
-        public virtual bool IgnoreCase()
+
+        public virtual bool IgnoreCase
         {
-            return (flags & IGNORE_CASE) != 0;
+            get
+            {
+                {
+                    return (flags & IGNORE_CASE) != 0;
+                }
+            }
         }
 
         /// <param name="singleMatch">  List<String>, the sequence of strings to match </param>
@@ -73,7 +84,7 @@ namespace Lucene.Net.Analysis.Synonym
                 {
                     // for now hardcode at 4.0, as its what the old code did.
                     // would be nice to fix, but shouldn't store a version in each submap!!!
-                    currMap.submap = new CharArrayMap<SlowSynonymMap>(Lucene.Net.Util.Version.LUCENE_CURRENT, 1, IgnoreCase());
+                    currMap.submap = new CharArrayMap<SlowSynonymMap>(Lucene.Net.Util.Version.LUCENE_CURRENT, 1, IgnoreCase);
                 }
 
                 var map = currMap.submap.Get(str);
@@ -102,7 +113,7 @@ namespace Lucene.Net.Analysis.Synonym
 
         public override string ToString()
         {
-            StringBuilder sb = new StringBuilder("<");
+            var sb = new StringBuilder("<");
             if (synonyms != null)
             {
                 sb.Append("[");


Mime
View raw message