Example usage for opennlp.tools.ngram NGramModel add

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

Introduction

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

Prototype

public void add(StringList ngram) 

Source Link

Document

Adds one NGram, if it already exists the count increase by one.

Usage

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);//  www .  jav  a  2s. 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);//from  ww  w.ja  v  a2  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);//w  w w .j a va2 s  . co m
    Assert.assertEquals(1, 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);
    ngramModel.remove(tokens);/*  www .  j  a v  a2 s.c  om*/
    Assert.assertEquals(0, ngramModel.size());
}

From source file:opennlp.tools.ngram.NGramModelTest.java

@Test
public void testContains() throws Exception {
    NGramModel ngramModel = new NGramModel();
    StringList tokens = new StringList("the", "bro", "wn");
    ngramModel.add(tokens);
    Assert.assertFalse(ngramModel.contains(new StringList("the")));
}