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


Java ErasureUtils.noop方法代码示例

本文整理汇总了Java中edu.stanford.nlp.util.ErasureUtils.noop方法的典型用法代码示例。如果您正苦于以下问题:Java ErasureUtils.noop方法的具体用法?Java ErasureUtils.noop怎么用?Java ErasureUtils.noop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.stanford.nlp.util.ErasureUtils的用法示例。


在下文中一共展示了ErasureUtils.noop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHeuristicDelta

import edu.stanford.nlp.util.ErasureUtils; //导入方法依赖的package包/类
/**
 * For a given coverage set C of a given hypothesis, this finds all the gaps
 * in the coverage set (e.g., if C = {1,5,10}, then gaps are 2-4 and 6-9), and
 * sums the future costs associated with all gaps (e.g., future-cost(2-4) +
 * future-cost(6-9)).
 * 
 * This is the same as in Moses, though this may sometimes over estimate
 * future cost with discontinuous phrases.
 */
@Override
public double getHeuristicDelta(Derivation<TK, FV> hyp,
    CoverageSet newCoverage) {

  double oldH = hyp.parent.h;
  double newH = 0.0;

  CoverageSet coverage = hyp.sourceCoverage;
  int startEdge = coverage.nextClearBit(0);

  if (Double.isNaN(oldH)) {
    System.err.printf("getHeuristicDelta:\n");
    System.err.printf("coverage: %s\n", hyp.sourceCoverage);
    System.err.println("old H: " + oldH);
    throw new RuntimeException();
  }

  int foreignSize = hyp.sourceSequence.size();
  for (int endEdge; startEdge < foreignSize; startEdge = coverage
      .nextClearBit(endEdge)) {
    endEdge = coverage.nextSetBit(startEdge);

    if (endEdge == -1) {
      endEdge = hyp.sourceSequence.size();
    }

    double localH = hSpanScores.getScore(startEdge, endEdge - 1);

    if (Double.isNaN(localH)) {
      System.err.printf("Bad retrieved score for %d:%d ==> %f\n", startEdge,
          endEdge - 1, localH);
      throw new RuntimeException();
    }

    newH += localH;
    if (Double.isNaN(newH)) {
      System.err.printf(
          "Bad total retrieved score for %d:%d ==> %f (localH=%f)\n",
          startEdge, endEdge - 1, newH, localH);
      throw new RuntimeException();
    }
  }
  if ((Double.isInfinite(newH) || newH == MINUS_INF)
      && (Double.isInfinite(oldH) || oldH == MINUS_INF))
    return 0.0;
  double delta = newH - oldH;
  ErasureUtils.noop(delta);
  return delta;
}
 
开发者ID:stanfordnlp,项目名称:phrasal,代码行数:59,代码来源:DTUIsolatedPhraseForeignCoverageHeuristic.java


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