Removes words that are too long or too short from the stream.

Note: Length is calculated as the number of Unicode codepoints.

Inheritance: Lucene.Net.Analysis.Util.FilteringTokenFilter
 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: public void testRandomStrings() throws java.io.IOException
 public virtual void testRandomStrings()
 {
     for (int i = 0; i < 10000; i++)
     {
       string text = TestUtil.randomUnicodeString(random(), 100);
       int min = TestUtil.Next(random(), 0, 100);
       int max = TestUtil.Next(random(), 0, 100);
       int count = text.codePointCount(0, text.Length);
       if (min > max)
       {
     int temp = min;
     min = max;
     max = temp;
       }
       bool expected = count >= min && count <= max;
       TokenStream stream = new KeywordTokenizer(new StringReader(text));
       stream = new CodepointCountFilter(TEST_VERSION_CURRENT, stream, min, max);
       stream.reset();
       assertEquals(expected, stream.incrementToken());
       stream.end();
       stream.close();
     }
 }
Ejemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void testRandomStrings() throws java.io.IOException
	  public virtual void testRandomStrings()
	  {
		for (int i = 0; i < 10000; i++)
		{
		  string text = TestUtil.randomUnicodeString(random(), 100);
		  int min = TestUtil.Next(random(), 0, 100);
		  int max = TestUtil.Next(random(), 0, 100);
		  int count = text.codePointCount(0, text.Length);
		  if (min > max)
		  {
			int temp = min;
			min = max;
			max = temp;
		  }
		  bool expected = count >= min && count <= max;
		  TokenStream stream = new KeywordTokenizer(new StringReader(text));
		  stream = new CodepointCountFilter(TEST_VERSION_CURRENT, stream, min, max);
		  stream.reset();
		  assertEquals(expected, stream.incrementToken());
		  stream.end();
		  stream.close();
		}
	  }
 //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);
     CodepointCountFilter filter = new CodepointCountFilter(TEST_VERSION_CURRENT, stream, 2, 6);
     assertTokenStreamContents(filter, new string[]{"short", "ab", "foo"}, new int[]{1, 4, 2});
 }
Ejemplo n.º 4
0
//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);
		CodepointCountFilter filter = new CodepointCountFilter(TEST_VERSION_CURRENT, stream, 2, 6);
		assertTokenStreamContents(filter, new string[]{"short", "ab", "foo"}, new int[]{1, 4, 2});
	  }