Example #1
0
 @Test
 public void testTrigrams() throws IOException {
   parmLen2.set(0, "This is a nice juicy test.");
   parmLen2.set(1, 3); // 3: trigrams	
   DefaultDataBag resBag =
       makeBag(
           new Tuple[] {
             TupleFac.newTuple(new String[] {"nice,juicy,test"}),
             TupleFac.newTuple(new String[] {"This,is,a"}),
             TupleFac.newTuple(new String[] {"is,a,nice"}),
             TupleFac.newTuple(new String[] {"a,nice,juicy"}),
           });
   assertTrue(compareBags(resBag, (DefaultDataBag) ngramFunc.exec(parmLen2)));
 }
Example #2
0
  @Test
  public void testBigrams() throws IOException {

    parmLen1.set(0, "This is a juicy test.");
    DefaultDataBag resBag =
        makeBag(
            new Tuple[] {
              TupleFac.newTuple(new String[] {"juicy,test"}),
              TupleFac.newTuple(new String[] {"is,a"}),
              TupleFac.newTuple(new String[] {"This,is"}),
              TupleFac.newTuple(new String[] {"a,juicy"}),
            });
    assertTrue(compareBags(resBag, (DefaultDataBag) ngramFunc.exec(parmLen1)));
  }