예제 #1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void doTestStopPositons(StopFilter stpf, boolean enableIcrements) throws java.io.IOException
        private void doTestStopPositons(StopFilter stpf, bool enableIcrements)
        {
            log("---> test with enable-increments-" + (enableIcrements?"enabled":"disabled"));
            stpf.EnablePositionIncrements = enableIcrements;
            CharTermAttribute          termAtt    = stpf.getAttribute(typeof(CharTermAttribute));
            PositionIncrementAttribute posIncrAtt = stpf.getAttribute(typeof(PositionIncrementAttribute));

            stpf.reset();
            for (int i = 0; i < 20; i += 3)
            {
                assertTrue(stpf.incrementToken());
                log("Token " + i + ": " + stpf);
                string w = English.intToEnglish(i).trim();
                assertEquals("expecting token " + i + " to be " + w, w, termAtt.ToString());
                assertEquals("all but first token must have position increment of 3", enableIcrements?(i == 0?1:3):1, posIncrAtt.PositionIncrement);
            }
            assertFalse(stpf.incrementToken());
            stpf.end();
            stpf.close();
        }
예제 #2
0
 //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
 //ORIGINAL LINE: private void doTestStopPositons(StopFilter stpf, boolean enableIcrements) throws java.io.IOException
 private void doTestStopPositons(StopFilter stpf, bool enableIcrements)
 {
     log("---> test with enable-increments-" + (enableIcrements?"enabled":"disabled"));
     stpf.EnablePositionIncrements = enableIcrements;
     CharTermAttribute termAtt = stpf.getAttribute(typeof(CharTermAttribute));
     PositionIncrementAttribute posIncrAtt = stpf.getAttribute(typeof(PositionIncrementAttribute));
     stpf.reset();
     for (int i = 0; i < 20; i += 3)
     {
       assertTrue(stpf.incrementToken());
       log("Token " + i + ": " + stpf);
       string w = English.intToEnglish(i).trim();
       assertEquals("expecting token " + i + " to be " + w,w,termAtt.ToString());
       assertEquals("all but first token must have position increment of 3",enableIcrements?(i == 0?1:3):1,posIncrAtt.PositionIncrement);
     }
     assertFalse(stpf.incrementToken());
     stpf.end();
     stpf.close();
 }