当前位置: 首页>>代码示例>>Java>>正文


Java ClassicCounter.keySet方法代码示例

本文整理汇总了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)));
  }
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:12,代码来源:AbstractEval.java

示例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)));
  }
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:12,代码来源:AbstractEval.java

示例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;
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:30,代码来源:BaseUnknownWordModelTrainer.java

示例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;
}
 
开发者ID:benblamey,项目名称:stanford-nlp,代码行数:33,代码来源:ChineseUnknownWordModelTrainer.java

示例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;
}
 
开发者ID:amark-india,项目名称:eventspotter,代码行数:33,代码来源:ChineseUnknownWordModelTrainer.java

示例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)));
  }
}
 
开发者ID:chbrown,项目名称:stanford-parser,代码行数:12,代码来源:AbstractEval.java


注:本文中的edu.stanford.nlp.stats.ClassicCounter.keySet方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。