Java Code Examples for

The following examples show how to use These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
public static void main(String args[]){
    String sampletext = "This is n-gram model";
    StringList tokens = new StringList(WhitespaceTokenizer.INSTANCE.tokenize(sampletext));
    System.out.println("Tokens " + tokens);
    NGramModel nGramModel = new NGramModel();
    nGramModel.add(tokens,2,4); // minlength and maxlength
    System.out.println("Total ngrams: " + nGramModel.numberOfGrams());
    for (StringList ngram : nGramModel) {
        System.out.println(nGramModel.getCount(ngram) + " - " + ngram);