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/12/10 19:39:01 UTC
[12/27] lucenenet git commit: adding converted analysis common tests
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestKeywordRepeatFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestKeywordRepeatFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestKeywordRepeatFilter.cs
new file mode 100644
index 0000000..e9674ba
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestKeywordRepeatFilter.cs
@@ -0,0 +1,48 @@
+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 SnowballFilter = org.apache.lucene.analysis.snowball.SnowballFilter;
+
+
+ public class TestKeywordRepeatFilter : BaseTokenStreamTestCase
+ {
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testBasic() throws java.io.IOException
+ public virtual void testBasic()
+ {
+ TokenStream ts = new RemoveDuplicatesTokenFilter(new SnowballFilter(new KeywordRepeatFilter(new MockTokenizer(new StringReader("the birds are flying"), MockTokenizer.WHITESPACE, false)), "English"));
+ assertTokenStreamContents(ts, new string[] {"the", "birds", "bird", "are", "flying", "fli"}, new int[] {1,1,0,1,1,0});
+ }
+
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testComposition() throws java.io.IOException
+ public virtual void testComposition()
+ {
+ TokenStream ts = new RemoveDuplicatesTokenFilter(new SnowballFilter(new KeywordRepeatFilter(new KeywordRepeatFilter(new MockTokenizer(new StringReader("the birds are flying"), MockTokenizer.WHITESPACE, false))), "English"));
+ assertTokenStreamContents(ts, new string[] {"the", "birds", "bird", "are", "flying", "fli"}, new int[] {1,1,0,1,1,0});
+ }
+
+
+
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLengthFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLengthFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLengthFilter.cs
new file mode 100644
index 0000000..750f4cf
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLengthFilter.cs
@@ -0,0 +1,86 @@
+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 org.apache.lucene.analysis;
+ using KeywordTokenizer = org.apache.lucene.analysis.core.KeywordTokenizer;
+ using Version = org.apache.lucene.util.Version;
+
+
+ using KeywordTokenizer = org.apache.lucene.analysis.core.KeywordTokenizer;
+ using Test = org.junit.Test;
+
+ public class TestLengthFilter : BaseTokenStreamTestCase
+ {
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testFilterNoPosIncr() throws Exception
+ public virtual void testFilterNoPosIncr()
+ {
+ TokenStream stream = new MockTokenizer(new StringReader("short toolong evenmuchlongertext a ab toolong foo"), MockTokenizer.WHITESPACE, false);
+ LengthFilter filter = new LengthFilter(Version.LUCENE_43, false, stream, 2, 6);
+ assertTokenStreamContents(filter, new string[]{"short", "ab", "foo"}, new int[]{1, 1, 1});
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testFilterWithPosIncr() throws Exception
+ public virtual void testFilterWithPosIncr()
+ {
+ TokenStream stream = new MockTokenizer(new StringReader("short toolong evenmuchlongertext a ab toolong foo"), MockTokenizer.WHITESPACE, false);
+ LengthFilter filter = new LengthFilter(TEST_VERSION_CURRENT, stream, 2, 6);
+ assertTokenStreamContents(filter, new string[]{"short", "ab", "foo"}, new int[]{1, 4, 2});
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testEmptyTerm() throws java.io.IOException
+ public virtual void testEmptyTerm()
+ {
+ Analyzer a = new AnalyzerAnonymousInnerClassHelper(this);
+ checkOneTerm(a, "", "");
+ }
+
+ private class AnalyzerAnonymousInnerClassHelper : Analyzer
+ {
+ private readonly TestLengthFilter outerInstance;
+
+ public AnalyzerAnonymousInnerClassHelper(TestLengthFilter outerInstance)
+ {
+ this.outerInstance = outerInstance;
+ }
+
+ protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+ {
+ Tokenizer tokenizer = new KeywordTokenizer(reader);
+ return new TokenStreamComponents(tokenizer, new LengthFilter(TEST_VERSION_CURRENT, tokenizer, 0, 5));
+ }
+ }
+
+ /// <summary>
+ /// checking the validity of constructor arguments
+ /// </summary>
+//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
+//ORIGINAL LINE: @Test(expected = IllegalArgumentException.class) public void testIllegalArguments() throws Exception
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+ public virtual void testIllegalArguments()
+ {
+ new LengthFilter(TEST_VERSION_CURRENT, new MockTokenizer(new StringReader("accept only valid arguments")), -4, -1);
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLengthFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLengthFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLengthFilterFactory.cs
new file mode 100644
index 0000000..6c990ab
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLengthFilterFactory.cs
@@ -0,0 +1,85 @@
+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 BaseTokenStreamFactoryTestCase = org.apache.lucene.analysis.util.BaseTokenStreamFactoryTestCase;
+ using ClasspathResourceLoader = org.apache.lucene.analysis.util.ClasspathResourceLoader;
+ using Version = org.apache.lucene.util.Version;
+
+ public class TestLengthFilterFactory : BaseTokenStreamFactoryTestCase
+ {
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void test() throws Exception
+ public virtual void test()
+ {
+ Reader reader = new StringReader("foo foobar super-duper-trooper");
+ TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+ stream = tokenFilterFactory("Length", Version.LUCENE_43, new ClasspathResourceLoader(this.GetType()), "min", "4", "max", "10", "enablePositionIncrements", "false").create(stream);
+ assertTokenStreamContents(stream, new string[] {"foobar"}, new int[] {1});
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testPositionIncrements() throws Exception
+ public virtual void testPositionIncrements()
+ {
+ Reader reader = new StringReader("foo foobar super-duper-trooper");
+ TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+ stream = tokenFilterFactory("Length", LengthFilterFactory.MIN_KEY, "4", LengthFilterFactory.MAX_KEY, "10").create(stream);
+ assertTokenStreamContents(stream, new string[] {"foobar"}, new int[] {2});
+ }
+
+ /// <summary>
+ /// Test that bogus arguments result in exception </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testBogusArguments() throws Exception
+ public virtual void testBogusArguments()
+ {
+ try
+ {
+ tokenFilterFactory("Length", LengthFilterFactory.MIN_KEY, "4", LengthFilterFactory.MAX_KEY, "5", "bogusArg", "bogusValue");
+ fail();
+ }
+ catch (System.ArgumentException expected)
+ {
+ assertTrue(expected.Message.contains("Unknown parameters"));
+ }
+ }
+
+ /// <summary>
+ /// Test that invalid arguments result in exception </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testInvalidArguments() throws Exception
+ public virtual void testInvalidArguments()
+ {
+ try
+ {
+ Reader reader = new StringReader("foo foobar super-duper-trooper");
+ TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+ tokenFilterFactory("Length", LengthFilterFactory.MIN_KEY, "5", LengthFilterFactory.MAX_KEY, "4").create(stream);
+ fail();
+ }
+ catch (System.ArgumentException expected)
+ {
+ assertTrue(expected.Message.contains("maximum length must not be greater than minimum length"));
+ }
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountAnalyzer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountAnalyzer.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountAnalyzer.cs
new file mode 100644
index 0000000..425b4a4
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountAnalyzer.cs
@@ -0,0 +1,103 @@
+using System.Text;
+
+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 Document = org.apache.lucene.document.Document;
+ using Field = org.apache.lucene.document.Field;
+ using DirectoryReader = org.apache.lucene.index.DirectoryReader;
+ using IndexReader = org.apache.lucene.index.IndexReader;
+ using IndexWriter = org.apache.lucene.index.IndexWriter;
+ using IndexWriterConfig = org.apache.lucene.index.IndexWriterConfig;
+ using Term = org.apache.lucene.index.Term;
+ using Directory = org.apache.lucene.store.Directory;
+ using TestUtil = org.apache.lucene.util.TestUtil;
+
+ public class TestLimitTokenCountAnalyzer : BaseTokenStreamTestCase
+ {
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testLimitTokenCountAnalyzer() throws java.io.IOException
+ public virtual void testLimitTokenCountAnalyzer()
+ {
+ foreach (bool consumeAll in new bool[] {true, false})
+ {
+ MockAnalyzer mock = new MockAnalyzer(random());
+
+ // if we are consuming all tokens, we can use the checks,
+ // otherwise we can't
+ mock.EnableChecks = consumeAll;
+ Analyzer a = new LimitTokenCountAnalyzer(mock, 2, consumeAll);
+
+ // dont use assertAnalyzesTo here, as the end offset is not the end of the string (unless consumeAll is true, in which case its correct)!
+ assertTokenStreamContents(a.tokenStream("dummy", "1 2 3 4 5"), new string[] {"1", "2"}, new int[] {0, 3}, new int[] {1, 4}, consumeAll ? 16 : null);
+ assertTokenStreamContents(a.tokenStream("dummy", "1 2 3 4 5"), new string[] {"1", "2"}, new int[] {0, 2}, new int[] {1, 3}, consumeAll ? 9 : null);
+
+ // less than the limit, ensure we behave correctly
+ assertTokenStreamContents(a.tokenStream("dummy", "1 "), new string[] {"1"}, new int[] {0}, new int[] {1}, consumeAll ? 3 : null);
+
+ // equal to limit
+ assertTokenStreamContents(a.tokenStream("dummy", "1 2 "), new string[] {"1", "2"}, new int[] {0, 3}, new int[] {1, 4}, consumeAll ? 6 : null);
+ }
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testLimitTokenCountIndexWriter() throws java.io.IOException
+ public virtual void testLimitTokenCountIndexWriter()
+ {
+
+ foreach (bool consumeAll in new bool[] {true, false})
+ {
+ Directory dir = newDirectory();
+ int limit = TestUtil.Next(random(), 50, 101000);
+ MockAnalyzer mock = new MockAnalyzer(random());
+
+ // if we are consuming all tokens, we can use the checks,
+ // otherwise we can't
+ mock.EnableChecks = consumeAll;
+ Analyzer a = new LimitTokenCountAnalyzer(mock, limit, consumeAll);
+
+ IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, a));
+
+ Document doc = new Document();
+ StringBuilder b = new StringBuilder();
+ for (int i = 1;i < limit;i++)
+ {
+ b.Append(" a");
+ }
+ b.Append(" x");
+ b.Append(" z");
+ doc.add(newTextField("field", b.ToString(), Field.Store.NO));
+ writer.addDocument(doc);
+ writer.close();
+
+ IndexReader reader = DirectoryReader.open(dir);
+ Term t = new Term("field", "x");
+ assertEquals(1, reader.docFreq(t));
+ t = new Term("field", "z");
+ assertEquals(0, reader.docFreq(t));
+ reader.close();
+ dir.close();
+ }
+ }
+
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilter.cs
new file mode 100644
index 0000000..3e5f7df
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilter.cs
@@ -0,0 +1,48 @@
+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 Test = org.junit.Test;
+
+ public class TestLimitTokenCountFilter : BaseTokenStreamTestCase
+ {
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void test() throws Exception
+ public virtual void test()
+ {
+ foreach (bool consumeAll in new bool[]{true, false})
+ {
+ MockTokenizer tokenizer = new MockTokenizer(new StringReader("A1 B2 C3 D4 E5 F6"), MockTokenizer.WHITESPACE, false);
+ tokenizer.EnableChecks = consumeAll;
+ TokenStream stream = new LimitTokenCountFilter(tokenizer, 3, consumeAll);
+ assertTokenStreamContents(stream, new string[]{"A1", "B2", "C3"});
+ }
+ }
+
+//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
+//ORIGINAL LINE: @Test(expected = IllegalArgumentException.class) public void testIllegalArguments() throws Exception
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+ public virtual void testIllegalArguments()
+ {
+ new LimitTokenCountFilter(new MockTokenizer(new StringReader("A1 B2 C3 D4 E5 F6"), MockTokenizer.WHITESPACE, false), -1);
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilterFactory.cs
new file mode 100644
index 0000000..3aec928
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilterFactory.cs
@@ -0,0 +1,79 @@
+using System;
+
+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 BaseTokenStreamFactoryTestCase = org.apache.lucene.analysis.util.BaseTokenStreamFactoryTestCase;
+
+
+ public class TestLimitTokenCountFilterFactory : BaseTokenStreamFactoryTestCase
+ {
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void test() throws Exception
+ public virtual void test()
+ {
+ foreach (bool consumeAll in new bool[]{true, false})
+ {
+ Reader reader = new StringReader("A1 B2 C3 D4 E5 F6");
+ MockTokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+ tokenizer.EnableChecks = consumeAll;
+ TokenStream stream = tokenizer;
+ stream = tokenFilterFactory("LimitTokenCount", LimitTokenCountFilterFactory.MAX_TOKEN_COUNT_KEY, "3", LimitTokenCountFilterFactory.CONSUME_ALL_TOKENS_KEY, Convert.ToString(consumeAll)).create(stream);
+ assertTokenStreamContents(stream, new string[]{"A1", "B2", "C3"});
+ }
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testRequired() throws Exception
+ public virtual void testRequired()
+ {
+ // param is required
+ try
+ {
+ tokenFilterFactory("LimitTokenCount");
+ fail();
+ }
+ catch (System.ArgumentException e)
+ {
+ assertTrue("exception doesn't mention param: " + e.Message, 0 < e.Message.indexOf(LimitTokenCountFilterFactory.MAX_TOKEN_COUNT_KEY));
+ }
+ }
+
+ /// <summary>
+ /// Test that bogus arguments result in exception
+ /// </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testBogusArguments() throws Exception
+ public virtual void testBogusArguments()
+ {
+ try
+ {
+ tokenFilterFactory("LimitTokenCount", LimitTokenCountFilterFactory.MAX_TOKEN_COUNT_KEY, "3", "bogusArg", "bogusValue");
+ fail();
+ }
+ catch (System.ArgumentException expected)
+ {
+ assertTrue(expected.Message.contains("Unknown parameters"));
+ }
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilter.cs
new file mode 100644
index 0000000..435e6fc
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilter.cs
@@ -0,0 +1,104 @@
+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 SynonymFilter = org.apache.lucene.analysis.synonym.SynonymFilter;
+ using SynonymMap = org.apache.lucene.analysis.synonym.SynonymMap;
+ using CharsRef = org.apache.lucene.util.CharsRef;
+ using Test = org.junit.Test;
+
+
+ public class TestLimitTokenPositionFilter : BaseTokenStreamTestCase
+ {
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testMaxPosition2() throws java.io.IOException
+ public virtual void testMaxPosition2()
+ {
+ foreach (bool consumeAll in new bool[]{true, false})
+ {
+ Analyzer a = new AnalyzerAnonymousInnerClassHelper(this);
+
+ // don't use assertAnalyzesTo here, as the end offset is not the end of the string (unless consumeAll is true, in which case its correct)!
+ assertTokenStreamContents(a.tokenStream("dummy", "1 2 3 4 5"), new string[]{"1", "2"}, new int[]{0, 3}, new int[]{1, 4}, consumeAll ? 16 : null);
+ assertTokenStreamContents(a.tokenStream("dummy", new StringReader("1 2 3 4 5")), new string[]{"1", "2"}, new int[]{0, 2}, new int[]{1, 3}, consumeAll ? 9 : null);
+
+ // less than the limit, ensure we behave correctly
+ assertTokenStreamContents(a.tokenStream("dummy", "1 "), new string[]{"1"}, new int[]{0}, new int[]{1}, consumeAll ? 3 : null);
+
+ // equal to limit
+ assertTokenStreamContents(a.tokenStream("dummy", "1 2 "), new string[]{"1", "2"}, new int[]{0, 3}, new int[]{1, 4}, consumeAll ? 6 : null);
+ }
+ }
+
+ private class AnalyzerAnonymousInnerClassHelper : Analyzer
+ {
+ private readonly TestLimitTokenPositionFilter outerInstance;
+
+ public AnalyzerAnonymousInnerClassHelper(TestLimitTokenPositionFilter outerInstance)
+ {
+ this.outerInstance = outerInstance;
+ }
+
+ protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+ {
+ MockTokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+ // if we are consuming all tokens, we can use the checks, otherwise we can't
+ tokenizer.EnableChecks = consumeAll;
+ return new TokenStreamComponents(tokenizer, new LimitTokenPositionFilter(tokenizer, 2, consumeAll));
+ }
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testMaxPosition3WithSynomyms() throws java.io.IOException
+ public virtual void testMaxPosition3WithSynomyms()
+ {
+ foreach (bool consumeAll in new bool[]{true, false})
+ {
+ MockTokenizer tokenizer = new MockTokenizer(new StringReader("one two three four five"), MockTokenizer.WHITESPACE, false);
+ // if we are consuming all tokens, we can use the checks, otherwise we can't
+ tokenizer.EnableChecks = consumeAll;
+
+ SynonymMap.Builder builder = new SynonymMap.Builder(true);
+ builder.add(new CharsRef("one"), new CharsRef("first"), true);
+ builder.add(new CharsRef("one"), new CharsRef("alpha"), true);
+ builder.add(new CharsRef("one"), new CharsRef("beguine"), true);
+ CharsRef multiWordCharsRef = new CharsRef();
+ SynonymMap.Builder.join(new string[]{"and", "indubitably", "single", "only"}, multiWordCharsRef);
+ builder.add(new CharsRef("one"), multiWordCharsRef, true);
+ SynonymMap.Builder.join(new string[]{"dopple", "ganger"}, multiWordCharsRef);
+ builder.add(new CharsRef("two"), multiWordCharsRef, true);
+ SynonymMap synonymMap = builder.build();
+ TokenStream stream = new SynonymFilter(tokenizer, synonymMap, true);
+ stream = new LimitTokenPositionFilter(stream, 3, consumeAll);
+
+ // "only", the 4th word of multi-word synonym "and indubitably single only" is not emitted, since its position is greater than 3.
+ assertTokenStreamContents(stream, new string[]{"one", "first", "alpha", "beguine", "and", "two", "indubitably", "dopple", "three", "single", "ganger"}, new int[]{1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0});
+ }
+ }
+
+//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
+//ORIGINAL LINE: @Test(expected = IllegalArgumentException.class) public void testIllegalArguments() throws Exception
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+ public virtual void testIllegalArguments()
+ {
+ new LimitTokenPositionFilter(new MockTokenizer(new StringReader("one two three four five")), 0);
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilterFactory.cs
new file mode 100644
index 0000000..22d8255
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilterFactory.cs
@@ -0,0 +1,105 @@
+using System;
+
+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 BaseTokenStreamFactoryTestCase = org.apache.lucene.analysis.util.BaseTokenStreamFactoryTestCase;
+
+
+ public class TestLimitTokenPositionFilterFactory : BaseTokenStreamFactoryTestCase
+ {
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testMaxPosition1() throws Exception
+ public virtual void testMaxPosition1()
+ {
+ foreach (bool consumeAll in new bool[]{true, false})
+ {
+ Reader reader = new StringReader("A1 B2 C3 D4 E5 F6");
+ MockTokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+ // if we are consuming all tokens, we can use the checks, otherwise we can't
+ tokenizer.EnableChecks = consumeAll;
+ TokenStream stream = tokenizer;
+ stream = tokenFilterFactory("LimitTokenPosition", LimitTokenPositionFilterFactory.MAX_TOKEN_POSITION_KEY, "1", LimitTokenPositionFilterFactory.CONSUME_ALL_TOKENS_KEY, Convert.ToString(consumeAll)).create(stream);
+ assertTokenStreamContents(stream, new string[]{"A1"});
+ }
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testMissingParam() throws Exception
+ public virtual void testMissingParam()
+ {
+ try
+ {
+ tokenFilterFactory("LimitTokenPosition");
+ fail();
+ }
+ catch (System.ArgumentException e)
+ {
+ assertTrue("exception doesn't mention param: " + e.Message, 0 < e.Message.indexOf(LimitTokenPositionFilterFactory.MAX_TOKEN_POSITION_KEY));
+ }
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testMaxPosition1WithShingles() throws Exception
+ public virtual void testMaxPosition1WithShingles()
+ {
+ foreach (bool consumeAll in new bool[]{true, false})
+ {
+ Reader reader = new StringReader("one two three four five");
+ MockTokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+ // if we are consuming all tokens, we can use the checks, otherwise we can't
+ tokenizer.EnableChecks = consumeAll;
+ TokenStream stream = tokenizer;
+ stream = tokenFilterFactory("Shingle", "minShingleSize", "2", "maxShingleSize", "3", "outputUnigrams", "true").create(stream);
+ stream = tokenFilterFactory("LimitTokenPosition", LimitTokenPositionFilterFactory.MAX_TOKEN_POSITION_KEY, "1", LimitTokenPositionFilterFactory.CONSUME_ALL_TOKENS_KEY, Convert.ToString(consumeAll)).create(stream);
+ assertTokenStreamContents(stream, new string[]{"one", "one two", "one two three"});
+ }
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testConsumeAllTokens() throws Exception
+ public virtual void testConsumeAllTokens()
+ {
+ Reader reader = new StringReader("A1 B2 C3 D4 E5 F6");
+ TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+ stream = tokenFilterFactory("LimitTokenPosition", "maxTokenPosition", "3", "consumeAllTokens", "true").create(stream);
+ assertTokenStreamContents(stream, new string[] {"A1", "B2", "C3"});
+ }
+
+ /// <summary>
+ /// Test that bogus arguments result in exception
+ /// </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testBogusArguments() throws Exception
+ public virtual void testBogusArguments()
+ {
+ try
+ {
+ tokenFilterFactory("LimitTokenPosition", "maxTokenPosition", "3", "bogusArg", "bogusValue");
+ fail();
+ }
+ catch (System.ArgumentException expected)
+ {
+ assertTrue(expected.Message.contains("Unknown parameters"));
+ }
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLucene47WordDelimiterFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLucene47WordDelimiterFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLucene47WordDelimiterFilter.cs
new file mode 100644
index 0000000..2e01f3a
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLucene47WordDelimiterFilter.cs
@@ -0,0 +1,446 @@
+using System;
+using System.Collections.Generic;
+
+/*
+ * 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 org.apache.lucene.analysis.miscellaneous
+{
+
+ using org.apache.lucene.analysis;
+ using KeywordTokenizer = org.apache.lucene.analysis.core.KeywordTokenizer;
+ using StopFilter = org.apache.lucene.analysis.core.StopFilter;
+ using StandardAnalyzer = org.apache.lucene.analysis.standard.StandardAnalyzer;
+ using PositionIncrementAttribute = org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
+ using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
+ using CharArraySet = org.apache.lucene.analysis.util.CharArraySet;
+ using Test = org.junit.Test;
+
+
+//JAVA TO C# CONVERTER TODO TASK: This Java 'import static' statement cannot be converted to C#:
+// import static org.apache.lucene.analysis.miscellaneous.WordDelimiterFilter.*;
+//JAVA TO C# CONVERTER TODO TASK: This Java 'import static' statement cannot be converted to C#:
+// import static org.apache.lucene.analysis.miscellaneous.WordDelimiterIterator.DEFAULT_WORD_DELIM_TABLE;
+
+ /// <summary>
+ /// New WordDelimiterFilter tests... most of the tests are in ConvertedLegacyTest
+ /// TODO: should explicitly test things like protWords and not rely on
+ /// the factory tests in Solr.
+ /// </summary>
+ [Obsolete]
+ public class TestLucene47WordDelimiterFilter : BaseTokenStreamTestCase
+ /// <summary>
+ ///*
+ /// public void testPerformance() throws IOException {
+ /// String s = "now is the time-for all good men to come to-the aid of their country.";
+ /// Token tok = new Token();
+ /// long start = System.currentTimeMillis();
+ /// int ret=0;
+ /// for (int i=0; i<1000000; i++) {
+ /// StringReader r = new StringReader(s);
+ /// TokenStream ts = new WhitespaceTokenizer(r);
+ /// ts = new WordDelimiterFilter(ts, 1,1,1,1,0);
+ ///
+ /// while (ts.next(tok) != null) ret++;
+ /// }
+ ///
+ /// System.out.println("ret="+ret+" time="+(System.currentTimeMillis()-start));
+ /// }
+ /// **
+ /// </summary>
+ {
+//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
+//ORIGINAL LINE: @Test public void testOffsets() throws java.io.IOException
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+ public virtual void testOffsets()
+ {
+ int flags = GENERATE_WORD_PARTS | GENERATE_NUMBER_PARTS | CATENATE_ALL | SPLIT_ON_CASE_CHANGE | SPLIT_ON_NUMERICS | STEM_ENGLISH_POSSESSIVE;
+ // test that subwords and catenated subwords have
+ // the correct offsets.
+ TokenFilter wdf = new Lucene47WordDelimiterFilter(new SingleTokenTokenStream(new Token("foo-bar", 5, 12)), DEFAULT_WORD_DELIM_TABLE, flags, null);
+
+ assertTokenStreamContents(wdf, new string[] {"foo", "bar", "foobar"}, new int[] {5, 9, 5}, new int[] {8, 12, 12}, null, null, null, null, false);
+
+ wdf = new Lucene47WordDelimiterFilter(new SingleTokenTokenStream(new Token("foo-bar", 5, 6)), DEFAULT_WORD_DELIM_TABLE, flags, null);
+
+ assertTokenStreamContents(wdf, new string[] {"foo", "bar", "foobar"}, new int[] {5, 5, 5}, new int[] {6, 6, 6}, null, null, null, null, false);
+ }
+
+//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
+//ORIGINAL LINE: @Test public void testOffsetChange() throws Exception
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+ public virtual void testOffsetChange()
+ {
+ int flags = GENERATE_WORD_PARTS | GENERATE_NUMBER_PARTS | CATENATE_ALL | SPLIT_ON_CASE_CHANGE | SPLIT_ON_NUMERICS | STEM_ENGLISH_POSSESSIVE;
+ TokenFilter wdf = new Lucene47WordDelimiterFilter(new SingleTokenTokenStream(new Token("übelkeit)", 7, 16)), DEFAULT_WORD_DELIM_TABLE, flags, null);
+
+ assertTokenStreamContents(wdf, new string[] {"übelkeit"}, new int[] {7}, new int[] {15});
+ }
+
+//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
+//ORIGINAL LINE: @Test public void testOffsetChange2() throws Exception
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+ public virtual void testOffsetChange2()
+ {
+ int flags = GENERATE_WORD_PARTS | GENERATE_NUMBER_PARTS | CATENATE_ALL | SPLIT_ON_CASE_CHANGE | SPLIT_ON_NUMERICS | STEM_ENGLISH_POSSESSIVE;
+ TokenFilter wdf = new Lucene47WordDelimiterFilter(new SingleTokenTokenStream(new Token("(übelkeit", 7, 17)), DEFAULT_WORD_DELIM_TABLE, flags, null);
+
+ assertTokenStreamContents(wdf, new string[] {"übelkeit"}, new int[] {8}, new int[] {17});
+ }
+
+//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
+//ORIGINAL LINE: @Test public void testOffsetChange3() throws Exception
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+ public virtual void testOffsetChange3()
+ {
+ int flags = GENERATE_WORD_PARTS | GENERATE_NUMBER_PARTS | CATENATE_ALL | SPLIT_ON_CASE_CHANGE | SPLIT_ON_NUMERICS | STEM_ENGLISH_POSSESSIVE;
+ TokenFilter wdf = new Lucene47WordDelimiterFilter(new SingleTokenTokenStream(new Token("(übelkeit", 7, 16)), DEFAULT_WORD_DELIM_TABLE, flags, null);
+
+ assertTokenStreamContents(wdf, new string[] {"übelkeit"}, new int[] {8}, new int[] {16});
+ }
+
+//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
+//ORIGINAL LINE: @Test public void testOffsetChange4() throws Exception
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+ public virtual void testOffsetChange4()
+ {
+ int flags = GENERATE_WORD_PARTS | GENERATE_NUMBER_PARTS | CATENATE_ALL | SPLIT_ON_CASE_CHANGE | SPLIT_ON_NUMERICS | STEM_ENGLISH_POSSESSIVE;
+ TokenFilter wdf = new Lucene47WordDelimiterFilter(new SingleTokenTokenStream(new Token("(foo,bar)", 7, 16)), DEFAULT_WORD_DELIM_TABLE, flags, null);
+
+ assertTokenStreamContents(wdf, new string[] {"foo", "bar", "foobar"}, new int[] {8, 12, 8}, new int[] {11, 15, 15}, null, null, null, null, false);
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void doSplit(final String input, String... output) throws Exception
+//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
+ public virtual void doSplit(string input, params string[] output)
+ {
+ int flags = GENERATE_WORD_PARTS | GENERATE_NUMBER_PARTS | SPLIT_ON_CASE_CHANGE | SPLIT_ON_NUMERICS | STEM_ENGLISH_POSSESSIVE;
+ MockTokenizer tokenizer = new MockTokenizer(new StringReader(input), MockTokenizer.KEYWORD, false);
+ TokenFilter wdf = new Lucene47WordDelimiterFilter(tokenizer, WordDelimiterIterator.DEFAULT_WORD_DELIM_TABLE, flags, null);
+
+ assertTokenStreamContents(wdf, output);
+ }
+
+//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
+//ORIGINAL LINE: @Test public void testSplits() throws Exception
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+ public virtual void testSplits()
+ {
+ doSplit("basic-split","basic","split");
+ doSplit("camelCase","camel","Case");
+
+ // non-space marking symbol shouldn't cause split
+ // this is an example in Thai
+ doSplit("\u0e1a\u0e49\u0e32\u0e19","\u0e1a\u0e49\u0e32\u0e19");
+ // possessive followed by delimiter
+ doSplit("test's'", "test");
+
+ // some russian upper and lowercase
+ doSplit("Роберт", "Роберт");
+ // now cause a split (russian camelCase)
+ doSplit("РобЕрт", "Роб", "Ерт");
+
+ // a composed titlecase character, don't split
+ doSplit("aDžungla", "aDžungla");
+
+ // a modifier letter, don't split
+ doSplit("ســـــــــــــــــلام", "ســـــــــــــــــلام");
+
+ // enclosing mark, don't split
+ doSplit("test⃝", "test⃝");
+
+ // combining spacing mark (the virama), don't split
+ doSplit("हिन्दी", "हिन्दी");
+
+ // don't split non-ascii digits
+ doSplit("١٢٣٤", "١٢٣٤");
+
+ // don't split supplementaries into unpaired surrogates
+ doSplit("𠀀𠀀", "𠀀𠀀");
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void doSplitPossessive(int stemPossessive, final String input, final String... output) throws Exception
+//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
+ public virtual void doSplitPossessive(int stemPossessive, string input, params string[] output)
+ {
+ int flags = GENERATE_WORD_PARTS | GENERATE_NUMBER_PARTS | SPLIT_ON_CASE_CHANGE | SPLIT_ON_NUMERICS;
+ flags |= (stemPossessive == 1) ? STEM_ENGLISH_POSSESSIVE : 0;
+ MockTokenizer tokenizer = new MockTokenizer(new StringReader(input), MockTokenizer.KEYWORD, false);
+ TokenFilter wdf = new Lucene47WordDelimiterFilter(tokenizer, flags, null);
+
+ assertTokenStreamContents(wdf, output);
+ }
+
+ /*
+ * Test option that allows disabling the special "'s" stemming, instead treating the single quote like other delimiters.
+ */
+//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
+//ORIGINAL LINE: @Test public void testPossessives() throws Exception
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+ public virtual void testPossessives()
+ {
+ doSplitPossessive(1, "ra's", "ra");
+ doSplitPossessive(0, "ra's", "ra", "s");
+ }
+
+ /*
+ * Set a large position increment gap of 10 if the token is "largegap" or "/"
+ */
+ private sealed class LargePosIncTokenFilter : TokenFilter
+ {
+ private readonly TestLucene47WordDelimiterFilter outerInstance;
+
+ internal CharTermAttribute termAtt = addAttribute(typeof(CharTermAttribute));
+ internal PositionIncrementAttribute posIncAtt = addAttribute(typeof(PositionIncrementAttribute));
+
+ protected internal LargePosIncTokenFilter(TestLucene47WordDelimiterFilter outerInstance, TokenStream input) : base(input)
+ {
+ this.outerInstance = outerInstance;
+ }
+
+//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 (input.incrementToken())
+ {
+ if (termAtt.ToString().Equals("largegap") || termAtt.ToString().Equals("/"))
+ {
+ posIncAtt.PositionIncrement = 10;
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
+//ORIGINAL LINE: @Test public void testPositionIncrements() throws Exception
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+ public virtual void testPositionIncrements()
+ {
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final int flags = GENERATE_WORD_PARTS | GENERATE_NUMBER_PARTS | CATENATE_ALL | SPLIT_ON_CASE_CHANGE | SPLIT_ON_NUMERICS | STEM_ENGLISH_POSSESSIVE;
+ int flags = GENERATE_WORD_PARTS | GENERATE_NUMBER_PARTS | CATENATE_ALL | SPLIT_ON_CASE_CHANGE | SPLIT_ON_NUMERICS | STEM_ENGLISH_POSSESSIVE;
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final org.apache.lucene.analysis.util.CharArraySet protWords = new org.apache.lucene.analysis.util.CharArraySet(TEST_VERSION_CURRENT, new HashSet<>(Arrays.asList("NUTCH")), false);
+ CharArraySet protWords = new CharArraySet(TEST_VERSION_CURRENT, new HashSet<>("NUTCH"), false);
+
+ /* analyzer that uses whitespace + wdf */
+ Analyzer a = new AnalyzerAnonymousInnerClassHelper(this, flags, protWords);
+
+ /* in this case, works as expected. */
+ assertAnalyzesTo(a, "LUCENE / SOLR", new string[] {"LUCENE", "SOLR"}, new int[] {0, 9}, new int[] {6, 13}, null, new int[] {1, 1}, null, false);
+
+ /* only in this case, posInc of 2 ?! */
+ assertAnalyzesTo(a, "LUCENE / solR", new string[] {"LUCENE", "sol", "R", "solR"}, new int[] {0, 9, 12, 9}, new int[] {6, 12, 13, 13}, null, new int[] {1, 1, 1, 0}, null, false);
+
+ assertAnalyzesTo(a, "LUCENE / NUTCH SOLR", new string[] {"LUCENE", "NUTCH", "SOLR"}, new int[] {0, 9, 15}, new int[] {6, 14, 19}, null, new int[] {1, 1, 1}, null, false);
+
+ /* analyzer that will consume tokens with large position increments */
+ Analyzer a2 = new AnalyzerAnonymousInnerClassHelper2(this, flags, protWords);
+
+ /* increment of "largegap" is preserved */
+ assertAnalyzesTo(a2, "LUCENE largegap SOLR", new string[] {"LUCENE", "largegap", "SOLR"}, new int[] {0, 7, 16}, new int[] {6, 15, 20}, null, new int[] {1, 10, 1}, null, false);
+
+ /* the "/" had a position increment of 10, where did it go?!?!! */
+ assertAnalyzesTo(a2, "LUCENE / SOLR", new string[] {"LUCENE", "SOLR"}, new int[] {0, 9}, new int[] {6, 13}, null, new int[] {1, 11}, null, false);
+
+ /* in this case, the increment of 10 from the "/" is carried over */
+ assertAnalyzesTo(a2, "LUCENE / solR", new string[] {"LUCENE", "sol", "R", "solR"}, new int[] {0, 9, 12, 9}, new int[] {6, 12, 13, 13}, null, new int[] {1, 11, 1, 0}, null, false);
+
+ assertAnalyzesTo(a2, "LUCENE / NUTCH SOLR", new string[] {"LUCENE", "NUTCH", "SOLR"}, new int[] {0, 9, 15}, new int[] {6, 14, 19}, null, new int[] {1, 11, 1}, null, false);
+
+ Analyzer a3 = new AnalyzerAnonymousInnerClassHelper3(this, flags, protWords);
+
+ assertAnalyzesTo(a3, "lucene.solr", new string[] {"lucene", "solr", "lucenesolr"}, new int[] {0, 7, 0}, new int[] {6, 11, 11}, null, new int[] {1, 1, 0}, null, false);
+
+ /* the stopword should add a gap here */
+ assertAnalyzesTo(a3, "the lucene.solr", new string[] {"lucene", "solr", "lucenesolr"}, new int[] {4, 11, 4}, new int[] {10, 15, 15}, null, new int[] {2, 1, 0}, null, false);
+ }
+
+ private class AnalyzerAnonymousInnerClassHelper : Analyzer
+ {
+ private readonly TestLucene47WordDelimiterFilter outerInstance;
+
+ private int flags;
+ private CharArraySet protWords;
+
+ public AnalyzerAnonymousInnerClassHelper(TestLucene47WordDelimiterFilter outerInstance, int flags, CharArraySet protWords)
+ {
+ this.outerInstance = outerInstance;
+ this.flags = flags;
+ this.protWords = protWords;
+ }
+
+ public override TokenStreamComponents createComponents(string field, Reader reader)
+ {
+ Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+ return new TokenStreamComponents(tokenizer, new Lucene47WordDelimiterFilter(tokenizer, flags, protWords));
+ }
+ }
+
+ private class AnalyzerAnonymousInnerClassHelper2 : Analyzer
+ {
+ private readonly TestLucene47WordDelimiterFilter outerInstance;
+
+ private int flags;
+ private CharArraySet protWords;
+
+ public AnalyzerAnonymousInnerClassHelper2(TestLucene47WordDelimiterFilter outerInstance, int flags, CharArraySet protWords)
+ {
+ this.outerInstance = outerInstance;
+ this.flags = flags;
+ this.protWords = protWords;
+ }
+
+ public override TokenStreamComponents createComponents(string field, Reader reader)
+ {
+ Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+ return new TokenStreamComponents(tokenizer, new Lucene47WordDelimiterFilter(new LargePosIncTokenFilter(outerInstance, tokenizer), flags, protWords));
+ }
+ }
+
+ private class AnalyzerAnonymousInnerClassHelper3 : Analyzer
+ {
+ private readonly TestLucene47WordDelimiterFilter outerInstance;
+
+ private int flags;
+ private CharArraySet protWords;
+
+ public AnalyzerAnonymousInnerClassHelper3(TestLucene47WordDelimiterFilter outerInstance, int flags, CharArraySet protWords)
+ {
+ this.outerInstance = outerInstance;
+ this.flags = flags;
+ this.protWords = protWords;
+ }
+
+ public override TokenStreamComponents createComponents(string field, Reader reader)
+ {
+ Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+ StopFilter filter = new StopFilter(TEST_VERSION_CURRENT, tokenizer, StandardAnalyzer.STOP_WORDS_SET);
+ return new TokenStreamComponents(tokenizer, new Lucene47WordDelimiterFilter(filter, flags, protWords));
+ }
+ }
+
+ /// <summary>
+ /// blast some random strings through the analyzer </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testRandomStrings() throws Exception
+ public virtual void testRandomStrings()
+ {
+ int numIterations = atLeast(5);
+ for (int i = 0; i < numIterations; i++)
+ {
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final int flags = random().nextInt(512);
+ int flags = random().Next(512);
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final org.apache.lucene.analysis.util.CharArraySet protectedWords;
+ CharArraySet protectedWords;
+ if (random().nextBoolean())
+ {
+ protectedWords = new CharArraySet(TEST_VERSION_CURRENT, new HashSet<>("a", "b", "cd"), false);
+ }
+ else
+ {
+ protectedWords = null;
+ }
+
+ Analyzer a = new AnalyzerAnonymousInnerClassHelper4(this, flags, protectedWords);
+ checkRandomData(random(), a, 200, 20, false, false);
+ }
+ }
+
+ private class AnalyzerAnonymousInnerClassHelper4 : Analyzer
+ {
+ private readonly TestLucene47WordDelimiterFilter outerInstance;
+
+ private int flags;
+ private CharArraySet protectedWords;
+
+ public AnalyzerAnonymousInnerClassHelper4(TestLucene47WordDelimiterFilter outerInstance, int flags, CharArraySet protectedWords)
+ {
+ this.outerInstance = outerInstance;
+ this.flags = flags;
+ this.protectedWords = protectedWords;
+ }
+
+
+ protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+ {
+ Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+ return new TokenStreamComponents(tokenizer, new Lucene47WordDelimiterFilter(tokenizer, flags, protectedWords));
+ }
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testEmptyTerm() throws java.io.IOException
+ public virtual void testEmptyTerm()
+ {
+ Random random = random();
+ for (int i = 0; i < 512; i++)
+ {
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final int flags = i;
+ int flags = i;
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final org.apache.lucene.analysis.util.CharArraySet protectedWords;
+ CharArraySet protectedWords;
+ if (random.nextBoolean())
+ {
+ protectedWords = new CharArraySet(TEST_VERSION_CURRENT, new HashSet<>("a", "b", "cd"), false);
+ }
+ else
+ {
+ protectedWords = null;
+ }
+
+ Analyzer a = new AnalyzerAnonymousInnerClassHelper5(this, flags, protectedWords);
+ // depending upon options, this thing may or may not preserve the empty term
+ checkAnalysisConsistency(random, a, random.nextBoolean(), "");
+ }
+ }
+
+ private class AnalyzerAnonymousInnerClassHelper5 : Analyzer
+ {
+ private readonly TestLucene47WordDelimiterFilter outerInstance;
+
+ private int flags;
+ private CharArraySet protectedWords;
+
+ public AnalyzerAnonymousInnerClassHelper5(TestLucene47WordDelimiterFilter outerInstance, int flags, CharArraySet protectedWords)
+ {
+ this.outerInstance = outerInstance;
+ this.flags = flags;
+ this.protectedWords = protectedWords;
+ }
+
+ protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+ {
+ Tokenizer tokenizer = new KeywordTokenizer(reader);
+ return new TokenStreamComponents(tokenizer, new Lucene47WordDelimiterFilter(tokenizer, flags, protectedWords));
+ }
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestPerFieldAnalyzerWrapper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestPerFieldAnalyzerWrapper.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestPerFieldAnalyzerWrapper.cs
new file mode 100644
index 0000000..f9139f6
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestPerFieldAnalyzerWrapper.cs
@@ -0,0 +1,110 @@
+using System.Collections.Generic;
+
+namespace org.apache.lucene.analysis.miscellaneous
+{
+
+
+ using org.apache.lucene.analysis;
+ using SimpleAnalyzer = org.apache.lucene.analysis.core.SimpleAnalyzer;
+ using WhitespaceAnalyzer = org.apache.lucene.analysis.core.WhitespaceAnalyzer;
+ using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
+ using IOUtils = org.apache.lucene.util.IOUtils;
+
+ /*
+ * 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.
+ */
+
+ public class TestPerFieldAnalyzerWrapper : BaseTokenStreamTestCase
+ {
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testPerField() throws Exception
+ public virtual void testPerField()
+ {
+ string text = "Qwerty";
+
+ IDictionary<string, Analyzer> analyzerPerField = new Dictionary<string, Analyzer>();
+ analyzerPerField["special"] = new SimpleAnalyzer(TEST_VERSION_CURRENT);
+
+ PerFieldAnalyzerWrapper analyzer = new PerFieldAnalyzerWrapper(new WhitespaceAnalyzer(TEST_VERSION_CURRENT), analyzerPerField);
+
+ TokenStream tokenStream = analyzer.tokenStream("field", text);
+ try
+ {
+ CharTermAttribute termAtt = tokenStream.getAttribute(typeof(CharTermAttribute));
+ tokenStream.reset();
+
+ assertTrue(tokenStream.incrementToken());
+ assertEquals("WhitespaceAnalyzer does not lowercase", "Qwerty", termAtt.ToString());
+ assertFalse(tokenStream.incrementToken());
+ tokenStream.end();
+ }
+ finally
+ {
+ IOUtils.closeWhileHandlingException(tokenStream);
+ }
+
+ tokenStream = analyzer.tokenStream("special", text);
+ try
+ {
+ CharTermAttribute termAtt = tokenStream.getAttribute(typeof(CharTermAttribute));
+ tokenStream.reset();
+
+ assertTrue(tokenStream.incrementToken());
+ assertEquals("SimpleAnalyzer lowercases", "qwerty", termAtt.ToString());
+ assertFalse(tokenStream.incrementToken());
+ tokenStream.end();
+ }
+ finally
+ {
+ IOUtils.closeWhileHandlingException(tokenStream);
+ }
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testCharFilters() throws Exception
+ public virtual void testCharFilters()
+ {
+ Analyzer a = new AnalyzerAnonymousInnerClassHelper(this);
+ assertAnalyzesTo(a, "ab", new string[] {"aab"}, new int[] {0}, new int[] {2});
+
+ // now wrap in PFAW
+ PerFieldAnalyzerWrapper p = new PerFieldAnalyzerWrapper(a, System.Linq.Enumerable.Empty<string, Analyzer>());
+
+ assertAnalyzesTo(p, "ab", new string[] {"aab"}, new int[] {0}, new int[] {2});
+ }
+
+ private class AnalyzerAnonymousInnerClassHelper : Analyzer
+ {
+ private readonly TestPerFieldAnalyzerWrapper outerInstance;
+
+ public AnalyzerAnonymousInnerClassHelper(TestPerFieldAnalyzerWrapper outerInstance)
+ {
+ this.outerInstance = outerInstance;
+ }
+
+ protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+ {
+ return new TokenStreamComponents(new MockTokenizer(reader));
+ }
+
+ protected internal override Reader initReader(string fieldName, Reader reader)
+ {
+ return new MockCharFilter(reader, 7);
+ }
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestPrefixAndSuffixAwareTokenFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestPrefixAndSuffixAwareTokenFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestPrefixAndSuffixAwareTokenFilter.cs
new file mode 100644
index 0000000..8defa09
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestPrefixAndSuffixAwareTokenFilter.cs
@@ -0,0 +1,42 @@
+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.
+ */
+
+
+
+ public class TestPrefixAndSuffixAwareTokenFilter : BaseTokenStreamTestCase
+ {
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void test() throws java.io.IOException
+ public virtual void test()
+ {
+
+ PrefixAndSuffixAwareTokenFilter ts = new PrefixAndSuffixAwareTokenFilter(new SingleTokenTokenStream(createToken("^", 0, 0)), new MockTokenizer(new StringReader("hello world"), MockTokenizer.WHITESPACE, false), new SingleTokenTokenStream(createToken("$", 0, 0)));
+
+ assertTokenStreamContents(ts, new string[] {"^", "hello", "world", "$"}, new int[] {0, 0, 6, 11}, new int[] {0, 5, 11, 11});
+ }
+
+ private static Token createToken(string term, int start, int offset)
+ {
+ return new Token(term, start, offset);
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestPrefixAwareTokenFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestPrefixAwareTokenFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestPrefixAwareTokenFilter.cs
new file mode 100644
index 0000000..7ef11d0
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestPrefixAwareTokenFilter.cs
@@ -0,0 +1,50 @@
+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.
+ */
+
+
+
+ public class TestPrefixAwareTokenFilter : BaseTokenStreamTestCase
+ {
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void test() throws java.io.IOException
+ public virtual void test()
+ {
+
+ PrefixAwareTokenFilter ts;
+
+ ts = new PrefixAwareTokenFilter(new SingleTokenTokenStream(createToken("a", 0, 1)), new SingleTokenTokenStream(createToken("b", 0, 1)));
+ assertTokenStreamContents(ts, new string[] {"a", "b"}, new int[] {0, 1}, new int[] {1, 2});
+
+ // prefix and suffix using 2x prefix
+
+ ts = new PrefixAwareTokenFilter(new SingleTokenTokenStream(createToken("^", 0, 0)), new MockTokenizer(new StringReader("hello world"), MockTokenizer.WHITESPACE, false));
+ ts = new PrefixAwareTokenFilter(ts, new SingleTokenTokenStream(createToken("$", 0, 0)));
+
+ assertTokenStreamContents(ts, new string[] {"^", "hello", "world", "$"}, new int[] {0, 0, 6, 11}, new int[] {0, 5, 11, 11});
+ }
+
+ private static Token createToken(string term, int start, int offset)
+ {
+ return new Token(term, start, offset);
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilter.cs
new file mode 100644
index 0000000..801ac17
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilter.cs
@@ -0,0 +1,231 @@
+using System.Collections.Generic;
+
+/*
+ * 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 org.apache.lucene.analysis.miscellaneous
+{
+
+ using KeywordTokenizer = org.apache.lucene.analysis.core.KeywordTokenizer;
+ using SynonymFilter = org.apache.lucene.analysis.synonym.SynonymFilter;
+ using SynonymMap = org.apache.lucene.analysis.synonym.SynonymMap;
+ using OffsetAttribute = org.apache.lucene.analysis.tokenattributes.OffsetAttribute;
+ using PositionIncrementAttribute = org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
+ using CharTermAttribute = org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
+ using CharsRef = org.apache.lucene.util.CharsRef;
+ using TestUtil = org.apache.lucene.util.TestUtil;
+
+
+ public class TestRemoveDuplicatesTokenFilter : BaseTokenStreamTestCase
+ {
+
+ public static Token tok(int pos, string t, int start, int end)
+ {
+ Token tok = new Token(t,start,end);
+ tok.PositionIncrement = pos;
+ return tok;
+ }
+ public static Token tok(int pos, string t)
+ {
+ return tok(pos, t, 0,0);
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testDups(final String expected, final org.apache.lucene.analysis.Token... tokens) throws Exception
+//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
+ public virtual void testDups(string expected, params Token[] tokens)
+ {
+
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final java.util.Iterator<org.apache.lucene.analysis.Token> toks = java.util.Arrays.asList(tokens).iterator();
+ IEnumerator<Token> toks = Arrays.asList(tokens).GetEnumerator();
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final org.apache.lucene.analysis.TokenStream ts = new RemoveDuplicatesTokenFilter((new org.apache.lucene.analysis.TokenStream()
+ TokenStream ts = new RemoveDuplicatesTokenFilter((new TokenStreamAnonymousInnerClassHelper(this, toks)));
+
+ assertTokenStreamContents(ts, expected.Split("\\s", true));
+ }
+
+ private class TokenStreamAnonymousInnerClassHelper : TokenStream
+ {
+ private readonly TestRemoveDuplicatesTokenFilter outerInstance;
+
+ private IEnumerator<Token> toks;
+
+ public TokenStreamAnonymousInnerClassHelper(TestRemoveDuplicatesTokenFilter outerInstance, IEnumerator<Token> toks)
+ {
+ this.outerInstance = outerInstance;
+ this.toks = toks;
+ termAtt = addAttribute(typeof(CharTermAttribute));
+ offsetAtt = addAttribute(typeof(OffsetAttribute));
+ posIncAtt = addAttribute(typeof(PositionIncrementAttribute));
+ }
+
+ internal CharTermAttribute termAtt;
+ internal OffsetAttribute offsetAtt;
+ internal PositionIncrementAttribute posIncAtt;
+ public override bool incrementToken()
+ {
+//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
+ if (toks.hasNext())
+ {
+ clearAttributes();
+//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
+ Token tok = toks.next();
+ termAtt.setEmpty().append(tok);
+ offsetAtt.setOffset(tok.startOffset(), tok.endOffset());
+ posIncAtt.PositionIncrement = tok.PositionIncrement;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testNoDups() throws Exception
+ public virtual void testNoDups()
+ {
+
+ testDups("A B B C D E",tok(1,"A", 0, 4),tok(1,"B", 5, 10),tok(1,"B",11, 15),tok(1,"C",16, 20),tok(0,"D",16, 20),tok(1,"E",21, 25));
+
+ }
+
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testSimpleDups() throws Exception
+ public virtual void testSimpleDups()
+ {
+
+ testDups("A B C D E",tok(1,"A", 0, 4),tok(1,"B", 5, 10),tok(0,"B",11, 15),tok(1,"C",16, 20),tok(0,"D",16, 20),tok(1,"E",21, 25));
+
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testComplexDups() throws Exception
+ public virtual void testComplexDups()
+ {
+
+ testDups("A B C D E F G H I J K",tok(1,"A"),tok(1,"B"),tok(0,"B"),tok(1,"C"),tok(1,"D"),tok(0,"D"),tok(0,"D"),tok(1,"E"),tok(1,"F"),tok(0,"F"),tok(1,"G"),tok(0,"H"),tok(0,"H"),tok(1,"I"),tok(1,"J"),tok(0,"K"),tok(0,"J"));
+
+ }
+
+ // some helper methods for the below test with synonyms
+ private string randomNonEmptyString()
+ {
+ while (true)
+ {
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final String s = org.apache.lucene.util.TestUtil.randomUnicodeString(random()).trim();
+ string s = TestUtil.randomUnicodeString(random()).trim();
+ if (s.Length != 0 && s.IndexOf('\u0000') == -1)
+ {
+ return s;
+ }
+ }
+ }
+
+ private void add(SynonymMap.Builder b, string input, string output, bool keepOrig)
+ {
+ b.add(new CharsRef(input.replaceAll(" +", "\u0000")), new CharsRef(output.replaceAll(" +", "\u0000")), keepOrig);
+ }
+
+ /// <summary>
+ /// blast some random strings through the analyzer </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testRandomStrings() throws Exception
+ public virtual void testRandomStrings()
+ {
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final int numIters = atLeast(10);
+ int numIters = atLeast(10);
+ for (int i = 0; i < numIters; i++)
+ {
+ SynonymMap.Builder b = new SynonymMap.Builder(random().nextBoolean());
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final int numEntries = atLeast(10);
+ int numEntries = atLeast(10);
+ for (int j = 0; j < numEntries; j++)
+ {
+ add(b, randomNonEmptyString(), randomNonEmptyString(), random().nextBoolean());
+ }
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final org.apache.lucene.analysis.synonym.SynonymMap map = b.build();
+ SynonymMap map = b.build();
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final boolean ignoreCase = random().nextBoolean();
+ bool ignoreCase = random().nextBoolean();
+
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final org.apache.lucene.analysis.Analyzer analyzer = new org.apache.lucene.analysis.Analyzer()
+ Analyzer analyzer = new AnalyzerAnonymousInnerClassHelper(this, map, ignoreCase);
+
+ checkRandomData(random(), analyzer, 200);
+ }
+ }
+
+ private class AnalyzerAnonymousInnerClassHelper : Analyzer
+ {
+ private readonly TestRemoveDuplicatesTokenFilter outerInstance;
+
+ private SynonymMap map;
+ private bool ignoreCase;
+
+ public AnalyzerAnonymousInnerClassHelper(TestRemoveDuplicatesTokenFilter outerInstance, SynonymMap map, bool ignoreCase)
+ {
+ this.outerInstance = outerInstance;
+ this.map = map;
+ this.ignoreCase = ignoreCase;
+ }
+
+ protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+ {
+ Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.SIMPLE, true);
+ TokenStream stream = new SynonymFilter(tokenizer, map, ignoreCase);
+ return new TokenStreamComponents(tokenizer, new RemoveDuplicatesTokenFilter(stream));
+ }
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testEmptyTerm() throws java.io.IOException
+ public virtual void testEmptyTerm()
+ {
+ Analyzer a = new AnalyzerAnonymousInnerClassHelper2(this);
+ checkOneTerm(a, "", "");
+ }
+
+ private class AnalyzerAnonymousInnerClassHelper2 : Analyzer
+ {
+ private readonly TestRemoveDuplicatesTokenFilter outerInstance;
+
+ public AnalyzerAnonymousInnerClassHelper2(TestRemoveDuplicatesTokenFilter outerInstance)
+ {
+ this.outerInstance = outerInstance;
+ }
+
+ protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+ {
+ Tokenizer tokenizer = new KeywordTokenizer(reader);
+ return new TokenStreamComponents(tokenizer, new RemoveDuplicatesTokenFilter(tokenizer));
+ }
+ }
+
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilterFactory.cs
new file mode 100644
index 0000000..0d07750
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestRemoveDuplicatesTokenFilterFactory.cs
@@ -0,0 +1,70 @@
+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 BaseTokenStreamFactoryTestCase = org.apache.lucene.analysis.util.BaseTokenStreamFactoryTestCase;
+
+ /// <summary>
+ /// Simple tests to ensure this factory is working </summary>
+ public class TestRemoveDuplicatesTokenFilterFactory : BaseTokenStreamFactoryTestCase
+ {
+
+ public static Token tok(int pos, string t, int start, int end)
+ {
+ Token tok = new Token(t,start,end);
+ tok.PositionIncrement = pos;
+ return tok;
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testDups(final String expected, final org.apache.lucene.analysis.Token... tokens) throws Exception
+//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
+ public virtual void testDups(string expected, params Token[] tokens)
+ {
+ TokenStream stream = new CannedTokenStream(tokens);
+ stream = tokenFilterFactory("RemoveDuplicates").create(stream);
+ assertTokenStreamContents(stream, expected.Split("\\s", true));
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testSimpleDups() throws Exception
+ public virtual void testSimpleDups()
+ {
+ testDups("A B C D E",tok(1,"A", 0, 4),tok(1,"B", 5, 10),tok(0,"B",11, 15),tok(1,"C",16, 20),tok(0,"D",16, 20),tok(1,"E",21, 25));
+ }
+
+ /// <summary>
+ /// Test that bogus arguments result in exception </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testBogusArguments() throws Exception
+ public virtual void testBogusArguments()
+ {
+ try
+ {
+ tokenFilterFactory("RemoveDuplicates", "bogusArg", "bogusValue");
+ fail();
+ }
+ catch (System.ArgumentException expected)
+ {
+ assertTrue(expected.Message.contains("Unknown parameters"));
+ }
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestScandinavianFoldingFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestScandinavianFoldingFilter.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestScandinavianFoldingFilter.cs
new file mode 100644
index 0000000..b087859
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestScandinavianFoldingFilter.cs
@@ -0,0 +1,155 @@
+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 KeywordTokenizer = org.apache.lucene.analysis.core.KeywordTokenizer;
+
+ public class TestScandinavianFoldingFilter : BaseTokenStreamTestCase
+ {
+
+
+ private Analyzer analyzer = new AnalyzerAnonymousInnerClassHelper();
+
+ private class AnalyzerAnonymousInnerClassHelper : Analyzer
+ {
+ public AnalyzerAnonymousInnerClassHelper()
+ {
+ }
+
+ protected internal override TokenStreamComponents createComponents(string field, Reader reader)
+ {
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final org.apache.lucene.analysis.Tokenizer tokenizer = new org.apache.lucene.analysis.MockTokenizer(reader, org.apache.lucene.analysis.MockTokenizer.WHITESPACE, false);
+ Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
+//ORIGINAL LINE: final org.apache.lucene.analysis.TokenStream stream = new ScandinavianFoldingFilter(tokenizer);
+ TokenStream stream = new ScandinavianFoldingFilter(tokenizer);
+ return new TokenStreamComponents(tokenizer, stream);
+ }
+ }
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void test() throws Exception
+ public virtual void test()
+ {
+
+ checkOneTerm(analyzer, "aeäaeeea", "aaaeea"); // should not cause ArrayOutOfBoundsException
+
+ checkOneTerm(analyzer, "aeäaeeeae", "aaaeea");
+ checkOneTerm(analyzer, "aeaeeeae", "aaeea");
+
+ checkOneTerm(analyzer, "bøen", "boen");
+ checkOneTerm(analyzer, "åene", "aene");
+
+
+ checkOneTerm(analyzer, "blåbærsyltetøj", "blabarsyltetoj");
+ checkOneTerm(analyzer, "blaabaarsyltetoej", "blabarsyltetoj");
+ checkOneTerm(analyzer, "blåbärsyltetöj", "blabarsyltetoj");
+
+ checkOneTerm(analyzer, "raksmorgas", "raksmorgas");
+ checkOneTerm(analyzer, "räksmörgås", "raksmorgas");
+ checkOneTerm(analyzer, "ræksmørgås", "raksmorgas");
+ checkOneTerm(analyzer, "raeksmoergaas", "raksmorgas");
+ checkOneTerm(analyzer, "ræksmörgaos", "raksmorgas");
+
+
+ checkOneTerm(analyzer, "ab", "ab");
+ checkOneTerm(analyzer, "ob", "ob");
+ checkOneTerm(analyzer, "Ab", "Ab");
+ checkOneTerm(analyzer, "Ob", "Ob");
+
+ checkOneTerm(analyzer, "å", "a");
+
+ checkOneTerm(analyzer, "aa", "a");
+ checkOneTerm(analyzer, "aA", "a");
+ checkOneTerm(analyzer, "ao", "a");
+ checkOneTerm(analyzer, "aO", "a");
+
+ checkOneTerm(analyzer, "AA", "A");
+ checkOneTerm(analyzer, "Aa", "A");
+ checkOneTerm(analyzer, "Ao", "A");
+ checkOneTerm(analyzer, "AO", "A");
+
+ checkOneTerm(analyzer, "æ", "a");
+ checkOneTerm(analyzer, "ä", "a");
+
+ checkOneTerm(analyzer, "Æ", "A");
+ checkOneTerm(analyzer, "Ä", "A");
+
+ checkOneTerm(analyzer, "ae", "a");
+ checkOneTerm(analyzer, "aE", "a");
+
+ checkOneTerm(analyzer, "Ae", "A");
+ checkOneTerm(analyzer, "AE", "A");
+
+
+ checkOneTerm(analyzer, "ö", "o");
+ checkOneTerm(analyzer, "ø", "o");
+ checkOneTerm(analyzer, "Ö", "O");
+ checkOneTerm(analyzer, "Ø", "O");
+
+
+ checkOneTerm(analyzer, "oo", "o");
+ checkOneTerm(analyzer, "oe", "o");
+ checkOneTerm(analyzer, "oO", "o");
+ checkOneTerm(analyzer, "oE", "o");
+
+ checkOneTerm(analyzer, "Oo", "O");
+ checkOneTerm(analyzer, "Oe", "O");
+ checkOneTerm(analyzer, "OO", "O");
+ checkOneTerm(analyzer, "OE", "O");
+ }
+
+ /// <summary>
+ /// check that the empty string doesn't cause issues </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testEmptyTerm() throws Exception
+ public virtual void testEmptyTerm()
+ {
+ Analyzer a = new AnalyzerAnonymousInnerClassHelper2(this);
+ checkOneTerm(a, "", "");
+ }
+
+ private class AnalyzerAnonymousInnerClassHelper2 : Analyzer
+ {
+ private readonly TestScandinavianFoldingFilter outerInstance;
+
+ public AnalyzerAnonymousInnerClassHelper2(TestScandinavianFoldingFilter outerInstance)
+ {
+ this.outerInstance = outerInstance;
+ }
+
+ protected internal override TokenStreamComponents createComponents(string fieldName, Reader reader)
+ {
+ Tokenizer tokenizer = new KeywordTokenizer(reader);
+ return new TokenStreamComponents(tokenizer, new ScandinavianFoldingFilter(tokenizer));
+ }
+ }
+
+ /// <summary>
+ /// blast some random strings through the analyzer </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testRandomData() throws Exception
+ public virtual void testRandomData()
+ {
+ checkRandomData(random(), analyzer, 1000 * RANDOM_MULTIPLIER);
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/c64856a7/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestScandinavianFoldingFilterFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestScandinavianFoldingFilterFactory.cs b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestScandinavianFoldingFilterFactory.cs
new file mode 100644
index 0000000..c7969cd
--- /dev/null
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestScandinavianFoldingFilterFactory.cs
@@ -0,0 +1,53 @@
+namespace org.apache.lucene.analysis.miscellaneous
+{
+
+ /// <summary>
+ /// Copyright 2004 The Apache Software Foundation
+ ///
+ /// Licensed 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>
+
+ using BaseTokenStreamFactoryTestCase = org.apache.lucene.analysis.util.BaseTokenStreamFactoryTestCase;
+
+
+ public class TestScandinavianFoldingFilterFactory : BaseTokenStreamFactoryTestCase
+ {
+
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testStemming() throws Exception
+ public virtual void testStemming()
+ {
+ Reader reader = new StringReader("räksmörgås");
+ TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false);
+ stream = tokenFilterFactory("ScandinavianFolding").create(stream);
+ assertTokenStreamContents(stream, new string[] {"raksmorgas"});
+ }
+
+ /// <summary>
+ /// Test that bogus arguments result in exception </summary>
+//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
+//ORIGINAL LINE: public void testBogusArguments() throws Exception
+ public virtual void testBogusArguments()
+ {
+ try
+ {
+ tokenFilterFactory("ScandinavianFolding", "bogusArg", "bogusValue");
+ fail();
+ }
+ catch (System.ArgumentException expected)
+ {
+ assertTrue(expected.Message.contains("Unknown parameters"));
+ }
+ }
+ }
+}
\ No newline at end of file