本文整理汇总了Java中edu.stanford.nlp.stats.ClassicCounter.keySet方法的典型用法代码示例。如果您正苦于以下问题:Java ClassicCounter.keySet方法的具体用法?Java ClassicCounter.keySet怎么用?Java ClassicCounter.keySet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.stats.ClassicCounter
的用法示例。
在下文中一共展示了ClassicCounter.keySet方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: display
import edu.stanford.nlp.stats.ClassicCounter; //导入方法依赖的package包/类
protected <T> void display(ClassicCounter<T> c, int num, PrintWriter pw) {
List<T> rules = new ArrayList<T>(c.keySet());
Collections.sort(rules, Counters.toComparatorDescending(c));
int rSize = rules.size();
if (num > rSize) {
num = rSize;
}
for (int i = 0; i < num; i++) {
pw.println(rules.get(i) + " " + c.getCount(rules.get(i)));
}
}
示例2: display
import edu.stanford.nlp.stats.ClassicCounter; //导入方法依赖的package包/类
private static <T> void display(ClassicCounter<T> c, int num, PrintWriter pw) {
List<T> rules = new ArrayList<T>(c.keySet());
Collections.sort(rules, Counters.toComparatorDescending(c));
int rSize = rules.size();
if (num > rSize) {
num = rSize;
}
for (int i = 0; i < num; i++) {
pw.println(rules.get(i) + " " + c.getCount(rules.get(i)));
}
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: display
import edu.stanford.nlp.stats.ClassicCounter; //导入方法依赖的package包/类
private static <T> void display(ClassicCounter<T> c, int num, PrintWriter pw) {
List<T> rules = new ArrayList<T>(c.keySet());
Collections.sort(rules, Counters.toComparatorDescending(c));
int rSize = rules.size();
if (num > rSize) {
num = rSize;
}
for (int i = 0; i < num; i++) {
logger.trace(rules.get(i) + " " + c.getCount(rules.get(i)));
}
}