Example usage for opennlp.tools.ngram NGramModel cutoff

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

Introduction

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

Prototype

public void cutoff(int cutoffUnder, int cutoffOver) 

Source Link

Document

Deletes all ngram which do appear less than the cutoffUnder value and more often than the cutoffOver value.

Usage

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);//  w  w  w .j a v a 2 s . co  m
    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);/*  w  w  w. j a va2  s. co m*/
    ngramModel.cutoff(1, 3);
    Assert.assertEquals(9, ngramModel.size());
}