本文整理汇总了Java中edu.stanford.nlp.stats.ClassicCounter.setCount方法的典型用法代码示例。如果您正苦于以下问题:Java ClassicCounter.setCount方法的具体用法?Java ClassicCounter.setCount怎么用?Java ClassicCounter.setCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.stats.ClassicCounter
的用法示例。
在下文中一共展示了ClassicCounter.setCount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import edu.stanford.nlp.stats.ClassicCounter; //导入方法依赖的package包/类
/**
* Calculate sister annotation statistics suitable for doing
* selective sister splitting in the PCFGParser inside the
* FactoredParser.
*
* @param args One argument: path to the Treebank
*/
public static void main(String[] args) {
ClassicCounter<String> c = new ClassicCounter<String>();
c.setCount("A", 0);
c.setCount("B", 1);
double d = Counters.klDivergence(c, c);
System.out.println("KL Divergence: " + d);
String encoding = "UTF-8";
if (args.length > 1) {
encoding = args[1];
}
if (args.length < 1) {
System.out.println("Usage: ParentAnnotationStats treebankPath");
} else {
SisterAnnotationStats pas = new SisterAnnotationStats();
Treebank treebank = new DiskTreebank(new TreeReaderFactory() {
public TreeReader newTreeReader(Reader in) {
return new PennTreeReader(in, new LabeledScoredTreeFactory(new StringLabelFactory()), new BobChrisTreeNormalizer());
}
}, encoding);
treebank.loadPath(args[0]);
treebank.apply(pas);
pas.printStats();
}
}
示例2: finishTraining
import edu.stanford.nlp.stats.ClassicCounter; //导入方法依赖的package包/类
public UnknownWordModel finishTraining() {
if (useGT) {
unknownGTTrainer.finishTraining();
}
for (Label tag : c.keySet()) {
/* outer iteration is over tags */
ClassicCounter<String> wc = c.get(tag); // counts for words given a tag
if (!tagHash.containsKey(tag)) {
tagHash.put(tag, new ClassicCounter<String>());
}
/* the UNKNOWN sequence is assumed to be seen once in each tag */
// This is sort of broken, but you can regard it as a Dirichlet prior.
tc.incrementCount(tag);
wc.setCount(unknown, 1.0);
/* inner iteration is over words */
for (String end : wc.keySet()) {
double prob = Math.log((wc.getCount(end)) / (tc.getCount(tag))); // p(sig|tag)
tagHash.get(tag).setCount(end, prob);
//if (Test.verbose)
//EncodingPrintWriter.out.println(tag + " rewrites as " + end + " endchar with probability " + prob,encoding);
}
}
return model;
}
示例3: finishTraining
import edu.stanford.nlp.stats.ClassicCounter; //导入方法依赖的package包/类
public UnknownWordModel finishTraining() {
Map<String,Float> unknownGT = null;
if (useGT) {
unknownGTTrainer.finishTraining();
unknownGT = unknownGTTrainer.unknownGT;
}
for (Label tagLab : c.keySet()) {
// outer iteration is over tags as Labels
ClassicCounter<String> wc = c.get(tagLab); // counts for words given a tag
if ( ! tagHash.containsKey(tagLab)) {
tagHash.put(tagLab, new ClassicCounter<String>());
}
// the UNKNOWN first character is assumed to be seen once in
// each tag
// this is really sort of broken! (why??)
tc.incrementCount(tagLab);
wc.setCount(unknown, 1.0);
// inner iteration is over words as strings
for (String first : wc.keySet()) {
double prob = Math.log(((wc.getCount(first))) / tc.getCount(tagLab));
tagHash.get(tagLab).setCount(first, prob);
//if (Test.verbose)
//EncodingPrintWriter.out.println(tag + " rewrites as " + first + " firstchar with probability " + prob,encoding);
}
}
return model;
}
示例4: finishTraining
import edu.stanford.nlp.stats.ClassicCounter; //导入方法依赖的package包/类
public UnknownWordModel finishTraining() {
HashMap<String,Float> unknownGT = null;
if (useGT) {
unknownGTTrainer.finishTraining();
unknownGT = unknownGTTrainer.unknownGT;
}
for (Label tagLab : c.keySet()) {
// outer iteration is over tags as Labels
ClassicCounter<String> wc = c.get(tagLab); // counts for words given a tag
if ( ! tagHash.containsKey(tagLab)) {
tagHash.put(tagLab, new ClassicCounter<String>());
}
// the UNKNOWN first character is assumed to be seen once in
// each tag
// this is really sort of broken! (why??)
tc.incrementCount(tagLab);
wc.setCount(unknown, 1.0);
// inner iteration is over words as strings
for (String first : wc.keySet()) {
double prob = Math.log(((wc.getCount(first))) / tc.getCount(tagLab));
tagHash.get(tagLab).setCount(first, prob);
//if (Test.verbose)
//EncodingPrintWriter.out.println(tag + " rewrites as " + first + " firstchar with probability " + prob,encoding);
}
}
return model;
}