public virtual void TestRandomHuge() { Random random = Random(); int numIters = AtLeast(3); for (int i = 0; i < numIters; i++) { b = new SynonymMap.Builder(random.nextBoolean()); int numEntries = AtLeast(10); if (VERBOSE) { Console.WriteLine("TEST: iter=" + i + " numEntries=" + numEntries); } for (int j = 0; j < numEntries; j++) { Add(RandomNonEmptyString(), RandomNonEmptyString(), random.nextBoolean()); } SynonymMap map = b.Build(); bool ignoreCase = random.nextBoolean(); Analyzer analyzer = new AnalyzerAnonymousInnerClassHelper4(this, map, ignoreCase); CheckRandomData(random, analyzer, 100, 1024); } }
/// <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); } }
public virtual void TestLotsOfConcatenating() { int flags = WordDelimiterFilter.GENERATE_WORD_PARTS | WordDelimiterFilter.GENERATE_NUMBER_PARTS | WordDelimiterFilter.CATENATE_WORDS | WordDelimiterFilter.CATENATE_NUMBERS | WordDelimiterFilter.CATENATE_ALL | WordDelimiterFilter.SPLIT_ON_CASE_CHANGE | WordDelimiterFilter.SPLIT_ON_NUMERICS | WordDelimiterFilter.STEM_ENGLISH_POSSESSIVE; /* analyzer that uses whitespace + wdf */ Analyzer a = new AnalyzerAnonymousInnerClassHelper4(this, flags); AssertAnalyzesTo(a, "abc-def-123-456", new string[] { "abc", "abcdef", "abcdef123456", "def", "123", "123456", "456" }, new int[] { 0, 0, 0, 4, 8, 8, 12 }, new int[] { 3, 7, 15, 7, 11, 15, 15 }, new int[] { 1, 0, 0, 1, 1, 0, 1 }); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testEmptyTerm() throws Exception public virtual void testEmptyTerm() { Random random = random(); Analyzer a = new AnalyzerAnonymousInnerClassHelper4(this); checkAnalysisConsistency(random, a, random.nextBoolean(), ""); Analyzer b = new AnalyzerAnonymousInnerClassHelper5(this); checkAnalysisConsistency(random, b, random.nextBoolean(), ""); }
public virtual void TestRandomStrings() { Analyzer a = new AnalyzerAnonymousInnerClassHelper3(this); CheckRandomData(Random(), a, 1000 * RANDOM_MULTIPLIER); Analyzer b = new AnalyzerAnonymousInnerClassHelper4(this); CheckRandomData(Random(), b, 1000 * RANDOM_MULTIPLIER); }
public virtual void TestRandomStrings() { Analyzer a = new AnalyzerAnonymousInnerClassHelper3(this); CheckRandomData(Random, a, 1000 * RandomMultiplier); Analyzer b = new AnalyzerAnonymousInnerClassHelper4(this); CheckRandomData(Random, b, 1000 * RandomMultiplier); }
/// <summary> /// concat numbers + words + all </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testLotsOfConcatenating() throws Exception public virtual void testLotsOfConcatenating() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int flags = GENERATE_WORD_PARTS | GENERATE_NUMBER_PARTS | CATENATE_WORDS | CATENATE_NUMBERS | CATENATE_ALL | SPLIT_ON_CASE_CHANGE | SPLIT_ON_NUMERICS | STEM_ENGLISH_POSSESSIVE; int flags = GENERATE_WORD_PARTS | GENERATE_NUMBER_PARTS | CATENATE_WORDS | CATENATE_NUMBERS | CATENATE_ALL | SPLIT_ON_CASE_CHANGE | SPLIT_ON_NUMERICS | STEM_ENGLISH_POSSESSIVE; /* analyzer that uses whitespace + wdf */ Analyzer a = new AnalyzerAnonymousInnerClassHelper4(this, flags); assertAnalyzesTo(a, "abc-def-123-456", new string[] { "abc", "abcdef", "abcdef123456", "def", "123", "123456", "456" }, new int[] { 0, 0, 0, 4, 8, 8, 12 }, new int[] { 3, 7, 15, 7, 11, 15, 15 }, new int[] { 1, 0, 0, 1, 1, 0, 1 }); }
public virtual void TestEmptyTerm() { Random random = Random(); Analyzer a = new AnalyzerAnonymousInnerClassHelper4(this); CheckAnalysisConsistency(random, a, random.nextBoolean(), ""); Analyzer b = new AnalyzerAnonymousInnerClassHelper5(this); CheckAnalysisConsistency(random, b, random.nextBoolean(), ""); }
public virtual void TestEmptyTerm() { CharArraySet dict = makeDictionary("a", "e", "i", "o", "u", "y", "bc", "def"); Analyzer a = new AnalyzerAnonymousInnerClassHelper4(this, dict); CheckOneTerm(a, "", ""); //InputSource @is = new InputSource(this.GetType().getResource("da_UTF8.xml").toExternalForm()); using (var @is = this.GetType().getResourceAsStream("da_UTF8.xml")) { HyphenationTree hyphenator = HyphenationCompoundWordTokenFilter.GetHyphenationTree(@is); Analyzer b = new AnalyzerAnonymousInnerClassHelper5(this, hyphenator); CheckOneTerm(b, "", ""); } }
public virtual void TestLetterHtmlishHuge() { Random random = Random; int maxLength = 1024; // this is number of elements, not chars! MockAnalyzer left = new MockAnalyzer(random, jvmLetter, false); left.MaxTokenLength = 255; // match CharTokenizer's max token length Analyzer right = new AnalyzerAnonymousInnerClassHelper4(this); int numIterations = AtLeast(50); for (int i = 0; i < numIterations; i++) { string s = TestUtil.RandomHtmlishString(random, maxLength); assertEquals(s, left.GetTokenStream("foo", newStringReader(s)), right.GetTokenStream("foo", newStringReader(s))); } }
public virtual void TestDoubleMockGraphTokenFilterRandom() { for (int iter = 0; iter < 10 * RANDOM_MULTIPLIER; iter++) { if (VERBOSE) { Console.WriteLine("\nTEST: iter=" + iter); } // Make new analyzer each time, because MGTF has fixed // seed: Analyzer a = new AnalyzerAnonymousInnerClassHelper4(this); Random random = Random; CheckRandomData(random, a, 5, AtLeast(100)); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testEmptyTerm() throws Exception public virtual void testEmptyTerm() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.apache.lucene.analysis.util.CharArraySet dict = makeDictionary("a", "e", "i", "o", "u", "y", "bc", "def"); CharArraySet dict = makeDictionary("a", "e", "i", "o", "u", "y", "bc", "def"); Analyzer a = new AnalyzerAnonymousInnerClassHelper4(this, dict); checkOneTerm(a, "", ""); InputSource @is = new InputSource(this.GetType().getResource("da_UTF8.xml").toExternalForm()); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.apache.lucene.analysis.compound.hyphenation.HyphenationTree hyphenator = HyphenationCompoundWordTokenFilter.getHyphenationTree(is); HyphenationTree hyphenator = HyphenationCompoundWordTokenFilter.getHyphenationTree(@is); Analyzer b = new AnalyzerAnonymousInnerClassHelper5(this, hyphenator); checkOneTerm(b, "", ""); }
public virtual void TestDoubleMockGraphTokenFilterRandom() { for (int iter = 0; iter < 10 * RANDOM_MULTIPLIER; iter++) { if (VERBOSE) { Console.WriteLine("\nTEST: iter=" + iter); } // Make new analyzer each time, because MGTF has fixed // seed: Analyzer a = new AnalyzerAnonymousInnerClassHelper4(this); Random random = Random(); CheckRandomData(random, a, 5, AtLeast(100)); } }
public virtual void TestRandomStrings() { int numIterations = AtLeast(5); for (int i = 0; i < numIterations; i++) { WordDelimiterFlags flags = (WordDelimiterFlags)Random().Next(512); CharArraySet protectedWords; if (Random().nextBoolean()) { protectedWords = new CharArraySet(TEST_VERSION_CURRENT, new string[] { "a", "b", "cd" }, false); } else { protectedWords = null; } Analyzer a = new AnalyzerAnonymousInnerClassHelper4(this, flags, protectedWords); CheckRandomData(Random(), a, 200, 20, false, false); } }
/// <summary> /// simple random test like testRandom2, but for larger docs /// </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testRandomHuge() throws Exception public virtual void testRandomHuge() { Random random = random(); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int numIters = atLeast(3); int numIters = atLeast(3); for (int i = 0; i < numIters; i++) { 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); if (VERBOSE) { Console.WriteLine("TEST: iter=" + i + " numEntries=" + numEntries); } for (int j = 0; j < numEntries; j++) { add(randomNonEmptyString(), randomNonEmptyString(), random.nextBoolean()); } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final 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 AnalyzerAnonymousInnerClassHelper4(this, map, ignoreCase); checkRandomData(random, analyzer, 100, 1024); } }
/// <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); } }
//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 AnalyzerAnonymousInnerClassHelper4(this); checkOneTerm(a, "", ""); }
public virtual void TestAllScripts() { Analyzer a = new AnalyzerAnonymousInnerClassHelper4(this); AssertAnalyzesTo(a, "多くの学生が試験に落ちた。", new string[] { "多く", "くの", "の学", "学生", "生が", "が試", "試験", "験に", "に落", "落ち", "ちた" }); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testAllScripts() throws Exception public virtual void testAllScripts() { Analyzer a = new AnalyzerAnonymousInnerClassHelper4(this); assertAnalyzesTo(a, "多くの学生が試験に落ちた。", new string[] {"多く", "くの", "の学", "学生", "生が", "が試", "試験", "験に", "に落", "落ち", "ちた"}); }
public virtual void TestMailtoBackwards() { Analyzer a = new AnalyzerAnonymousInnerClassHelper4(this); AssertAnalyzesTo(a, "mailto:[email protected]", new string[] { "mailto:test", "example.org" }); }
/// <summary> /// concat numbers + words + all </summary> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testLotsOfConcatenating() throws Exception public virtual void testLotsOfConcatenating() { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int flags = GENERATE_WORD_PARTS | GENERATE_NUMBER_PARTS | CATENATE_WORDS | CATENATE_NUMBERS | CATENATE_ALL | SPLIT_ON_CASE_CHANGE | SPLIT_ON_NUMERICS | STEM_ENGLISH_POSSESSIVE; int flags = GENERATE_WORD_PARTS | GENERATE_NUMBER_PARTS | CATENATE_WORDS | CATENATE_NUMBERS | CATENATE_ALL | SPLIT_ON_CASE_CHANGE | SPLIT_ON_NUMERICS | STEM_ENGLISH_POSSESSIVE; /* analyzer that uses whitespace + wdf */ Analyzer a = new AnalyzerAnonymousInnerClassHelper4(this, flags); assertAnalyzesTo(a, "abc-def-123-456", new string[] {"abc", "abcdef", "abcdef123456", "def", "123", "123456", "456"}, new int[] {0, 0, 0, 4, 8, 8, 12}, new int[] {3, 7, 15, 7, 11, 15, 15}, new int[] {1, 0, 0, 1, 1, 0, 1}); }
public virtual void TestRandomStrings() { int numIterations = AtLeast(5); for (int i = 0; i < numIterations; i++) { int flags = Random().Next(512); CharArraySet protectedWords; if (Random().nextBoolean()) { protectedWords = new CharArraySet(TEST_VERSION_CURRENT, new string[] { "a", "b", "cd" }, false); } else { protectedWords = null; } Analyzer a = new AnalyzerAnonymousInnerClassHelper4(this, flags, protectedWords); CheckRandomData(Random(), a, 200, 20, false, false); } }
public virtual void TestEmptyTerm() { Analyzer a = new AnalyzerAnonymousInnerClassHelper4(this); CheckOneTerm(a, "", ""); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void testLetterHtmlishHuge() throws Exception public virtual void testLetterHtmlishHuge() { Random random = random(); int maxLength = 1024; // this is number of elements, not chars! MockAnalyzer left = new MockAnalyzer(random, jvmLetter, false); left.MaxTokenLength = 255; // match CharTokenizer's max token length Analyzer right = new AnalyzerAnonymousInnerClassHelper4(this); int numIterations = atLeast(50); for (int i = 0; i < numIterations; i++) { string s = TestUtil.randomHtmlishString(random, maxLength); assertEquals(s, left.tokenStream("foo", newStringReader(s)), right.tokenStream("foo", newStringReader(s))); } }