List of usage examples for opennlp.tools.languagemodel LanguageModelTestUtils generateRandomVocabulary
public static Collection<String[]> generateRandomVocabulary(int size)
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); }