Exemplo n.º 1
0
        /// <summary>
        /// Test CommonGramsQueryFilter when first and last words are stopwords.
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void TestFirstAndLastStopWord() throws Exception
        public virtual void TestFirstAndLastStopWord()
        {
            const string      input = "the of";
            MockTokenizer     wt    = new MockTokenizer(new StringReader(input), MockTokenizer.WHITESPACE, false);
            CommonGramsFilter cgf   = new CommonGramsFilter(TEST_VERSION_CURRENT, wt, commonWords);
            TokenFilter       nsf   = new CommonGramsQueryFilter(cgf);

            assertTokenStreamContents(nsf, new string[] { "the_of" });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Test CommonGramsQueryFilter in the case of a single word query
        /// </summary>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void testOneWordQuery() throws Exception
        public virtual void testOneWordQuery()
        {
            const string      input = "monster";
            MockTokenizer     wt    = new MockTokenizer(new StringReader(input), MockTokenizer.WHITESPACE, false);
            CommonGramsFilter cgf   = new CommonGramsFilter(TEST_VERSION_CURRENT, wt, commonWords);
            TokenFilter       nsf   = new CommonGramsQueryFilter(cgf);

            assertTokenStreamContents(nsf, new string[] { "monster" });
        }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void testQueryReset() throws Exception
        public virtual void testQueryReset()
        {
            const string           input = "How the s a brown s cow d like A B thing?";
            WhitespaceTokenizer    wt    = new WhitespaceTokenizer(TEST_VERSION_CURRENT, new StringReader(input));
            CommonGramsFilter      cgf   = new CommonGramsFilter(TEST_VERSION_CURRENT, wt, commonWords);
            CommonGramsQueryFilter nsf   = new CommonGramsQueryFilter(cgf);

            CharTermAttribute term = wt.addAttribute(typeof(CharTermAttribute));

            nsf.reset();
            assertTrue(nsf.incrementToken());
            assertEquals("How_the", term.ToString());
            assertTrue(nsf.incrementToken());
            assertEquals("the_s", term.ToString());
            nsf.close();

            wt.Reader = new StringReader(input);
            nsf.reset();
            assertTrue(nsf.incrementToken());
            assertEquals("How_the", term.ToString());
        }
Exemplo n.º 4
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public void testQueryReset() throws Exception
        public virtual void testQueryReset()
        {
            const string input = "How the s a brown s cow d like A B thing?";
            WhitespaceTokenizer wt = new WhitespaceTokenizer(TEST_VERSION_CURRENT, new StringReader(input));
            CommonGramsFilter cgf = new CommonGramsFilter(TEST_VERSION_CURRENT, wt, commonWords);
            CommonGramsQueryFilter nsf = new CommonGramsQueryFilter(cgf);

            CharTermAttribute term = wt.addAttribute(typeof(CharTermAttribute));
            nsf.reset();
            assertTrue(nsf.incrementToken());
            assertEquals("How_the", term.ToString());
            assertTrue(nsf.incrementToken());
            assertEquals("the_s", term.ToString());
            nsf.close();

            wt.Reader = new StringReader(input);
            nsf.reset();
            assertTrue(nsf.incrementToken());
            assertEquals("How_the", term.ToString());
        }
Exemplo n.º 5
0
 /// <summary>
 /// Test CommonGramsQueryFilter in the case of a single (stop)word query
 /// </summary>
 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: public void testOneWordQueryStopWord() throws Exception
 public virtual void testOneWordQueryStopWord()
 {
     const string input = "the";
     MockTokenizer wt = new MockTokenizer(new StringReader(input), MockTokenizer.WHITESPACE, false);
     CommonGramsFilter cgf = new CommonGramsFilter(TEST_VERSION_CURRENT, wt, commonWords);
     TokenFilter nsf = new CommonGramsQueryFilter(cgf);
     assertTokenStreamContents(nsf, new string[] {"the"});
 }