@@ -0,0 +1,1907 @@
+package edu.cmu.sphinx.linguist.language.ngram.large;%0D%0A%0D%0Aimport edu.cmu.sphinx.linguist.language.ngram.large.LargeNGramModel;%0D%0Aimport edu.cmu.sphinx.linguist.WordSequence;%0D%0Aimport edu.cmu.sphinx.linguist.dictionary.Word;%0D%0A%0D%0Aimport java.util.*;%0D%0A%0D%0A/**%0D%0A * Use a largeNGramModel that also can be adjusted depending on context.%0D%0A * A model that optimizes the search by giving a preference to %0D%0A * the list of keywords.%0D%0A * %3Cp%3E%0D%0A * Example of use in calling program using config file:%0D%0A * %3Cbr%3E%0D%0A * %3Ccode%3E%0D%0A *         KeywordOptimizerLargeNGramModel model = %0D%0A *      %09(KeywordOptimizerLargeNGramModel) cm.lookup(%22trigramModel%22);%0D%0A *         model.keywordProbs = this.hashProbs;%0D%0A *          %3C/code%3E %3Cp%3E%0D%0A * Create hashProbs by loading keywords and changes to probabilities,%0D%0A *    string, float pairs. Keywords may be all lower case.%3Cbr%3E%0D%0A *    %3Ccode%3E%0D%0A *    hashProbs.put(%22keyword%22, 0.5f);  %3C/code%3E%0D%0A * @author daktari3%0D%0A * @version 2010-12-16%0D%0A * @see LargeNGramModel%0D%0A * @see KeywordOptimizerModel%0D%0A *%0D%0A */%0D%0A%0D%0Apublic class KeywordOptimizerLargeNGramModel extends LargeNGramModel %7B%0D%0A%09%0D%0A%09   /**%0D%0A%09    * hash map of probability adjustments settable by%0D%0A%09    * user program.%0D%0A%09    * %0D%0A%09    */%0D%0A%09   public HashMap%3CString, Float%3E keywordProbs;%0D%0A%0D%0A    /**%0D%0A     * Gets the ngram probability of the word sequence represented by the word list%0D%0A     *%0D%0A     * @param wordSequence the word sequence%0D%0A     * @return the probability of the word sequence. Probability is in logMath log base%0D%0A     */%0D%0A    @Override%0D%0A    public float getProbability(WordSequence wordSequence) %7B%0D%0A    %09float prob = super.getProbability(wordSequence);%0D%0A    %09%0D%0A    %09if (keywordProbs == null)%0D%0A    %09%09%09return prob;%0D%0A    %09%0D%0A    %09for (Word word : wordSequence.getWords()) %7B%0D%0A    %09%09String ws = word.toString();%0D%0A    %09%09if (keywordProbs.containsKey(ws)) %7B%0D%0A    %09%09%09prob *= keywordProbs.get(ws);%0D%0A    %09%09%7D%0D%0A    %09%7D%0D%0A    %09%0D%0A    %09return prob;%0D%0A    %7D%0D%0A%0D%0A%7D%0D%0A

Add model combining LargeNGramModel and KeywordOptimizerModel