List of usage examples for opennlp.tools.languagemodel LanguageModelTestUtils generateRandomSentence
public static String[] generateRandomSentence()
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 w w w .j a v a 2 s .c o m } double probability = model.calculateProbability(LanguageModelTestUtils.generateRandomSentence()); Assert.assertTrue("a probability measure should be between 0 and 1 [was " + probability + "]", probability >= 0 && probability <= 1); }