Example usage for opennlp.tools.languagemodel LanguageModelTestUtils generateRandomVocabulary

List of usage examples for opennlp.tools.languagemodel LanguageModelTestUtils generateRandomVocabulary

Introduction

In this page you can find the example usage for opennlp.tools.languagemodel LanguageModelTestUtils generateRandomVocabulary.

Prototype

public static Collection<String[]> generateRandomVocabulary(int size) 

Source Link

Usage

From source file:opennlp.tools.languagemodel.NgramLanguageModelTest.java

@Test
public void testRandomVocabularyAndSentence() throws Exception {
    NGramLanguageModel model = new NGramLanguageModel();
    for (StringList sentence : LanguageModelTestUtils.generateRandomVocabulary(10)) {
        model.add(sentence, 2, 3);/*from www.j  av  a2  s  .c  om*/
    }
    double probability = model.calculateProbability(LanguageModelTestUtils.generateRandomSentence());
    Assert.assertTrue("a probability measure should be between 0 and 1 [was " + probability + "]",
            probability >= 0 && probability <= 1);
}