示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void testStopListPositions() throws java.io.IOException
        public virtual void testStopListPositions()
        {
            CharArraySet stopWordsSet = new CharArraySet(TEST_VERSION_CURRENT, asSet("good", "test", "analyzer"), false);
            StopAnalyzer newStop      = new StopAnalyzer(TEST_VERSION_CURRENT, stopWordsSet);
            string       s            = "This is a good test of the english stop analyzer with positions";

            int[]       expectedIncr = new int[] { 1, 1, 1, 3, 1, 1, 1, 2, 1 };
            TokenStream stream       = newStop.tokenStream("test", s);

            try
            {
                assertNotNull(stream);
                int i = 0;
                CharTermAttribute          termAtt    = stream.getAttribute(typeof(CharTermAttribute));
                PositionIncrementAttribute posIncrAtt = stream.addAttribute(typeof(PositionIncrementAttribute));

                stream.reset();
                while (stream.incrementToken())
                {
                    string text = termAtt.ToString();
                    assertFalse(stopWordsSet.contains(text));
                    assertEquals(expectedIncr[i++], posIncrAtt.PositionIncrement);
                }
                stream.end();
            }
            finally
            {
                IOUtils.closeWhileHandlingException(stream);
            }
        }
示例#2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void testDefaults() throws java.io.IOException
        public virtual void testDefaults()
        {
            assertTrue(stop != null);
            TokenStream stream = stop.tokenStream("test", "This is a test of the english stop analyzer");

            try
            {
                assertTrue(stream != null);
                CharTermAttribute termAtt = stream.getAttribute(typeof(CharTermAttribute));
                stream.reset();

                while (stream.incrementToken())
                {
                    assertFalse(inValidTokens.Contains(termAtt.ToString()));
                }
                stream.end();
            }
            finally
            {
                IOUtils.closeWhileHandlingException(stream);
            }
        }
示例#3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void testStopList() throws java.io.IOException
        public virtual void testStopList()
        {
            CharArraySet stopWordsSet = new CharArraySet(TEST_VERSION_CURRENT, asSet("good", "test", "analyzer"), false);
            StopAnalyzer newStop      = new StopAnalyzer(TEST_VERSION_CURRENT, stopWordsSet);
            TokenStream  stream       = newStop.tokenStream("test", "This is a good test of the english stop analyzer");

            try
            {
                assertNotNull(stream);
                CharTermAttribute termAtt = stream.getAttribute(typeof(CharTermAttribute));

                stream.reset();
                while (stream.incrementToken())
                {
                    string text = termAtt.ToString();
                    assertFalse(stopWordsSet.contains(text));
                }
                stream.end();
            }
            finally
            {
                IOUtils.closeWhileHandlingException(stream);
            }
        }
示例#4
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public void testStopList() throws java.io.IOException
        public virtual void testStopList()
        {
            CharArraySet stopWordsSet = new CharArraySet(TEST_VERSION_CURRENT, asSet("good", "test", "analyzer"), false);
            StopAnalyzer newStop = new StopAnalyzer(TEST_VERSION_CURRENT, stopWordsSet);
            TokenStream stream = newStop.tokenStream("test", "This is a good test of the english stop analyzer");
            try
            {
              assertNotNull(stream);
              CharTermAttribute termAtt = stream.getAttribute(typeof(CharTermAttribute));

              stream.reset();
              while (stream.incrementToken())
              {
            string text = termAtt.ToString();
            assertFalse(stopWordsSet.contains(text));
              }
              stream.end();
            }
            finally
            {
              IOUtils.closeWhileHandlingException(stream);
            }
        }
示例#5
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: public void testStopListPositions() throws java.io.IOException
        public virtual void testStopListPositions()
        {
            CharArraySet stopWordsSet = new CharArraySet(TEST_VERSION_CURRENT, asSet("good", "test", "analyzer"), false);
            StopAnalyzer newStop = new StopAnalyzer(TEST_VERSION_CURRENT, stopWordsSet);
            string s = "This is a good test of the english stop analyzer with positions";
            int[] expectedIncr = new int[] {1, 1, 1, 3, 1, 1, 1, 2, 1};
            TokenStream stream = newStop.tokenStream("test", s);
            try
            {
              assertNotNull(stream);
              int i = 0;
              CharTermAttribute termAtt = stream.getAttribute(typeof(CharTermAttribute));
              PositionIncrementAttribute posIncrAtt = stream.addAttribute(typeof(PositionIncrementAttribute));

              stream.reset();
              while (stream.incrementToken())
              {
            string text = termAtt.ToString();
            assertFalse(stopWordsSet.contains(text));
            assertEquals(expectedIncr[i++],posIncrAtt.PositionIncrement);
              }
              stream.end();
            }
            finally
            {
              IOUtils.closeWhileHandlingException(stream);
            }
        }