List of usage examples for opennlp.tools.ngram NGramModel size
public int size()
From source file:opennlp.tools.ngram.NGramModelTest.java
@Test public void testZeroGetCount() throws Exception { NGramModel ngramModel = new NGramModel(); int count = ngramModel.getCount(new StringList("")); Assert.assertEquals(0, count);//w ww .j a v a 2 s .c o m Assert.assertEquals(0, ngramModel.size()); }
From source file:opennlp.tools.ngram.NGramModelTest.java
@Test public void testZeroGetCount2() throws Exception { NGramModel ngramModel = new NGramModel(); ngramModel.add(new StringList("the", "bro", "wn")); int count = ngramModel.getCount(new StringList("fox")); Assert.assertEquals(0, count);/*w w w .j ava 2 s . com*/ Assert.assertEquals(1, ngramModel.size()); }
From source file:opennlp.tools.ngram.NGramModelTest.java
@Test public void testAdd() throws Exception { NGramModel ngramModel = new NGramModel(); ngramModel.add(new StringList("the", "bro", "wn")); int count = ngramModel.getCount(new StringList("the")); Assert.assertEquals(0, count);/* w w w .j a v a 2 s . c o m*/ Assert.assertEquals(1, ngramModel.size()); }
From source file:opennlp.tools.ngram.NGramModelTest.java
@Test public void testAdd1() throws Exception { NGramModel ngramModel = new NGramModel(); ngramModel.add(new StringList("the", "bro", "wn")); int count = ngramModel.getCount(new StringList("the", "bro", "wn")); Assert.assertEquals(1, count);// www .j av a 2 s. c o m Assert.assertEquals(1, ngramModel.size()); }
From source file:opennlp.tools.ngram.NGramModelTest.java
@Test public void testAdd2() throws Exception { NGramModel ngramModel = new NGramModel(); ngramModel.add(new StringList("the", "bro", "wn"), 2, 3); int count = ngramModel.getCount(new StringList("the", "bro", "wn")); Assert.assertEquals(1, count);// w w w. j av a 2 s. co m Assert.assertEquals(3, ngramModel.size()); }
From source file:opennlp.tools.ngram.NGramModelTest.java
@Test public void testAdd3() throws Exception { NGramModel ngramModel = new NGramModel(); ngramModel.add(new StringList("the", "brown", "fox"), 2, 3); int count = ngramModel.getCount(new StringList("the", "brown", "fox")); Assert.assertEquals(1, count);/*w w w .j a va2 s. c o m*/ count = ngramModel.getCount(new StringList("the", "brown")); Assert.assertEquals(1, count); count = ngramModel.getCount(new StringList("brown", "fox")); Assert.assertEquals(1, count); Assert.assertEquals(3, ngramModel.size()); }
From source file:opennlp.tools.ngram.NGramModelTest.java
@Test public void testRemove() throws Exception { NGramModel ngramModel = new NGramModel(); StringList tokens = new StringList("the", "bro", "wn"); ngramModel.add(tokens);/*from w w w . jav a 2 s . c om*/ ngramModel.remove(tokens); Assert.assertEquals(0, ngramModel.size()); }
From source file:opennlp.tools.ngram.NGramModelTest.java
@Test public void testCutoff1() throws Exception { NGramModel ngramModel = new NGramModel(); StringList tokens = new StringList("the", "brown", "fox", "jumped"); ngramModel.add(tokens, 1, 3);/*from w w w.j ava 2 s . c om*/ ngramModel.cutoff(2, 4); Assert.assertEquals(0, ngramModel.size()); }
From source file:opennlp.tools.ngram.NGramModelTest.java
@Test public void testCutoff2() throws Exception { NGramModel ngramModel = new NGramModel(); StringList tokens = new StringList("the", "brown", "fox", "jumped"); ngramModel.add(tokens, 1, 3);//from w ww .jav a2 s . c om ngramModel.cutoff(1, 3); Assert.assertEquals(9, ngramModel.size()); }