Example usage for opennlp.tools.ngram NGramModel toDictionary

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

Introduction

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

Prototype

public Dictionary toDictionary() 

Source Link

Document

Creates a dictionary which contain all StringList which are in the current NGramModel .

Usage

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

@Test
public void testToDictionary() throws Exception {
    NGramModel ngramModel = new NGramModel();
    StringList tokens = new StringList("the", "brown", "fox", "jumped");
    ngramModel.add(tokens, 1, 3);/*  w w  w  . ja  v  a  2s . c  o  m*/
    tokens = new StringList("the", "brown", "Fox", "jumped");
    ngramModel.add(tokens, 1, 3);
    Dictionary dictionary = ngramModel.toDictionary();
    Assert.assertNotNull(dictionary);
    Assert.assertEquals(9, dictionary.size());
    Assert.assertEquals(1, dictionary.getMinTokenCount());
    Assert.assertEquals(3, dictionary.getMaxTokenCount());
}