Beispiel #1
0
 /**
  * Scores a tagging for a sentence. Note that a tag sequence not accepted by the markov process
  * should receive a log score of Double.NEGATIVE_INFINITY.
  */
 public double scoreTagging(TaggedSentence taggedSentence) {
   double logScore = 0.0;
   List<LabeledLocalTrigramContext> labeledLocalTrigramContexts =
       extractLabeledLocalTrigramContexts(taggedSentence);
   for (LabeledLocalTrigramContext labeledLocalTrigramContext : labeledLocalTrigramContexts) {
     Counter<String> logScoreCounter =
         localTrigramScorer.getLogScoreCounter(labeledLocalTrigramContext);
     String currentTag = labeledLocalTrigramContext.getCurrentTag();
     if (logScoreCounter.containsKey(currentTag)) {
       logScore += logScoreCounter.getCount(currentTag);
     } else {
       logScore += Double.NEGATIVE_INFINITY;
     }
   }
   return logScore;
 }
Beispiel #2
0
 public boolean contains(K token) {
   return lm.containsKey(token);
 }
Beispiel #3
0
 public double getProb(K token) {
   if (unkTokens.contains(token) || !lm.containsKey(token)) return UNK_PROB;
   return lm.getCount(token);
 }