private void assertPartsOfSpeech(String input, params String[] partsOfSpeech)
        {
            TokenStream ts = analyzer.GetTokenStream("ignored", input);

            try
            {
                IPartOfSpeechAttribute partOfSpeechAtt = ts.AddAttribute <IPartOfSpeechAttribute>();
                ts.Reset();
                foreach (String partOfSpeech in partsOfSpeech)
                {
                    assertTrue(ts.IncrementToken());
                    assertEquals(partOfSpeech, partOfSpeechAtt.GetPartOfSpeech());
                }
                assertFalse(ts.IncrementToken());
                ts.End();
            }
            finally
            {
                IOUtils.DisposeWhileHandlingException(ts);
            }
        }
示例#2
0
        protected override bool Accept()
        {
            string pos = posAtt.GetPartOfSpeech();

            return(pos is null || !stopTags.Contains(pos));
        }