本文整理汇总了Java中edu.stanford.nlp.stats.ClassicCounter.getCount方法的典型用法代码示例。如果您正苦于以下问题:Java ClassicCounter.getCount方法的具体用法?Java ClassicCounter.getCount怎么用?Java ClassicCounter.getCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.stats.ClassicCounter
的用法示例。
在下文中一共展示了ClassicCounter.getCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createGraphFromPaths
import edu.stanford.nlp.stats.ClassicCounter; //导入方法依赖的package包/类
public static <T> TransducerGraph createGraphFromPaths(ClassicCounter<List<T>> pathCounter, int markovOrder) {
TransducerGraph graph = new TransducerGraph(); // empty
for (Iterator<List<T>> pathIter = pathCounter.keySet().iterator(); pathIter.hasNext();) {
List<T> path = pathIter.next();
double count = pathCounter.getCount(path);
addOnePathToGraph(path, count, markovOrder, graph);
}
return graph;
}
示例2: score
import edu.stanford.nlp.stats.ClassicCounter; //导入方法依赖的package包/类
public float score(IntTaggedWord itw) {
float logProb;
String word = itw.wordString();
// Label tag = itw.tagLabel();
String tagStr = itw.tagString();
Label tag = new Tag(tagStr);
// testing
//EncodingPrintWriter.out.println("Scoring unknown word " + word + " with tag " + tag,encoding);
// end testing
if (useEnd || useFirst || useFirstCap) {
String end = getSignature(word, -1); // The getSignature here doesn't use sentence position
if (useGT && ! seenEnd.contains(end)) {
logProb = scoreGT(tag);
} else {
if ( ! seenEnd.contains(end)) {
end = unknown;
}
//System.out.println("using end-character model for for unknown word "+ word + " for tag " + tag);
/* get the Counter of terminal rewrites for the relevant tag */
ClassicCounter<String> wordProbs = tagHash.get(tag);
/* if the proposed tag has never been seen before, issue a
* warning and return probability 0
*/
if (wordProbs == null) {
System.err.println("Warning: proposed tag is unseen in training data:\t"+tag);
logProb = Float.NEGATIVE_INFINITY;
} else if (wordProbs.keySet().contains(end)) {
logProb = (float) wordProbs.getCount(end);
} else {
logProb = (float) wordProbs.getCount(unknown);
}
}
} else if (useGT) {
logProb = scoreGT(tag);
} else {
System.err.println("Warning: no unknown word model in place!\nGiving the combination " + word + ' ' + tag + " zero probability.");
logProb = Float.NEGATIVE_INFINITY; // should never get this!
}
//EncodingPrintWriter.out.println("Unknown word estimate for " + word + " as " + tag + ": " + logProb,encoding); //debugging
return logProb;
}
示例3: score
import edu.stanford.nlp.stats.ClassicCounter; //导入方法依赖的package包/类
public float score(IntTaggedWord itw, String word) {
float logProb;
// Label tag = itw.tagLabel();
String tagStr = itw.tagString(tagIndex);
Label tag = new Tag(tagStr);
// testing
//EncodingPrintWriter.out.println("Scoring unknown word " + word + " with tag " + tag,encoding);
// end testing
if (useEnd || useFirst || useFirstCap) {
String end = getSignature(word, -1); // The getSignature here doesn't use sentence position
if (useGT && ! seenEnd.contains(end)) {
logProb = scoreGT(tagStr);
} else {
if ( ! seenEnd.contains(end)) {
end = unknown;
}
//System.out.println("using end-character model for for unknown word "+ word + " for tag " + tag);
/* get the Counter of terminal rewrites for the relevant tag */
ClassicCounter<String> wordProbs = tagHash.get(tag);
/* if the proposed tag has never been seen before, issue a
* warning and return probability 0
*/
if (wordProbs == null) {
System.err.println("Warning: proposed tag is unseen in training data:\t"+tagStr);
logProb = Float.NEGATIVE_INFINITY;
} else if (wordProbs.keySet().contains(end)) {
logProb = (float) wordProbs.getCount(end);
} else {
logProb = (float) wordProbs.getCount(unknown);
}
}
} else if (useGT) {
logProb = scoreGT(tagStr);
} else {
System.err.println("Warning: no unknown word model in place!\nGiving the combination " + word + ' ' + tagStr + " zero probability.");
logProb = Float.NEGATIVE_INFINITY; // should never get this!
}
//EncodingPrintWriter.out.println("Unknown word estimate for " + word + " as " + tag + ": " + logProb,encoding); //debugging
return logProb;
}