Example usage for opennlp.tools.ngram NGramModel getCount

List of usage examples for opennlp.tools.ngram NGramModel getCount

Introduction

In this page you can find the example usage for opennlp.tools.ngram NGramModel getCount.

Prototype

public int getCount(StringList ngram) 

Source Link

Document

Retrieves the count of the given ngram.

Usage

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);/*from   w  w w.j  a  v a2s  . 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);// ww w .  j  a  va 2 s  .c om
    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  . java2 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);/*from w ww  .  jav a 2s .co  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 . ja v a2  s .c o  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);/*from  w  ww  .j a v  a2s.  co 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());
}