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


Java GeneralizedCounter类代码示例

本文整理汇总了Java中edu.stanford.nlp.stats.GeneralizedCounter的典型用法代码示例。如果您正苦于以下问题:Java GeneralizedCounter类的具体用法?Java GeneralizedCounter怎么用?Java GeneralizedCounter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: logProbs

import edu.stanford.nlp.stats.GeneralizedCounter; //导入依赖的package包/类
public GeneralizedCounter logProbs(int position, int window) {
  GeneralizedCounter<E> gc = new GeneralizedCounter<E>(window);
  int[] labels = new int[window];
  // cdm july 2005: below array initialization isn't necessary: JLS (3rd ed.)
  // 4.12.5
  // Arrays.fill(labels, 0);

  OUTER: while (true) {
    List<E> labelsList = intArrayToListE(labels);
    gc.incrementCount(labelsList, logProb(position, labels));
    for (int i = 0; i < labels.length; i++) {
      labels[i]++;
      if (labels[i] < numClasses) {
        break;
      }
      if (i == labels.length - 1) {
        break OUTER;
      }
      labels[i] = 0;
    }
  }
  return gc;
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:24,代码来源:CRFCliqueTree.java

示例2: probs

import edu.stanford.nlp.stats.GeneralizedCounter; //导入依赖的package包/类
public GeneralizedCounter probs(int position, int window) {
  GeneralizedCounter<E> gc = new GeneralizedCounter<E>(window);
  int[] labels = new int[window];
  // cdm july 2005: below array initialization isn't necessary: JLS (3rd ed.)
  // 4.12.5
  // Arrays.fill(labels, 0);

  OUTER: while (true) {
    List<E> labelsList = intArrayToListE(labels);
    gc.incrementCount(labelsList, prob(position, labels));
    for (int i = 0; i < labels.length; i++) {
      labels[i]++;
      if (labels[i] < numClasses) {
        break;
      }
      if (i == labels.length - 1) {
        break OUTER;
      }
      labels[i] = 0;
    }
  }
  return gc;
}
 
开发者ID:paulirwin,项目名称:Stanford.NER.Net,代码行数:24,代码来源:CRFCliqueTree.java

示例3: train

import edu.stanford.nlp.stats.GeneralizedCounter; //导入依赖的package包/类
public void train(Collection<Tree> trees) {
  Numberer tagNumberer = Numberer.getGlobalNumberer("tags");
  lex.train(trees);
  ClassicCounter<String> initial = new ClassicCounter<String>();
  GeneralizedCounter ruleCounter = new GeneralizedCounter(2);
  for (Tree tree : trees) {
    List<Label> tags = tree.preTerminalYield();
    String last = null;
    for (Label tagLabel : tags) {
      String tag = tagLabel.value();
      tagNumberer.number(tag);
      if (last == null) {
        initial.incrementCount(tag);
      } else {
        ruleCounter.incrementCount2D(last, tag);
      }
      last = tag;
    }
  }
  int numTags = tagNumberer.total();
  POSes = new HashSet<String>(ErasureUtils.<Collection<String>>uncheckedCast(tagNumberer.objects()));
  initialPOSDist = Distribution.laplaceSmoothedDistribution(initial, numTags, 0.5);
  markovPOSDists = new HashMap<String, Distribution>();
  Set entries = ruleCounter.lowestLevelCounterEntrySet();
  for (Iterator iter = entries.iterator(); iter.hasNext();) {
    Map.Entry entry = (Map.Entry) iter.next();
    //      Map.Entry<List<String>, Counter> entry = (Map.Entry<List<String>, Counter>) iter.next();
    Distribution d = Distribution.laplaceSmoothedDistribution((ClassicCounter) entry.getValue(), numTags, 0.5);
    markovPOSDists.put(((List<String>) entry.getKey()).get(0), d);
  }
}
 
开发者ID:FabianFriedrich,项目名称:Text2Process,代码行数:32,代码来源:ChineseMarkovWordSegmenter.java

示例4: initializeTraining

import edu.stanford.nlp.stats.GeneralizedCounter; //导入依赖的package包/类
@Override
public void initializeTraining(double numTrees) {
  lex.initializeTraining(numTrees);

  this.initial = new ClassicCounter<String>();
  this.ruleCounter = new GeneralizedCounter(2);
}
 
开发者ID:amark-india,项目名称:eventspotter,代码行数:8,代码来源:ChineseMarkovWordSegmenter.java


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