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


Java ClassicCounter.getCount方法代码示例

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

示例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;
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:47,代码来源:BaseUnknownWordModel.java

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


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