本文整理汇总了Java中edu.berkeley.nlp.util.Counter.setCount方法的典型用法代码示例。如果您正苦于以下问题:Java Counter.setCount方法的具体用法?Java Counter.setCount怎么用?Java Counter.setCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.berkeley.nlp.util.Counter
的用法示例。
在下文中一共展示了Counter.setCount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: relax
import edu.berkeley.nlp.util.Counter; //导入方法依赖的package包/类
private void relax(Counter<Edge<V>> pathCosts,
Map<Edge<V>, V> intermediateStates,
Map<V, List<Edge<V>>> closedUnaryRulesByChild,
Map<V, List<Edge<V>>> closedUnaryRulesByParent, Edge<V> unaryRule,
V intermediateState, double newScore) {
if (intermediateState != null
&& (intermediateState.equals(unaryRule.getParent()) || intermediateState
.equals(unaryRule.getChild())))
return;
boolean isNewRule = !pathCosts.containsKey(unaryRule);
double oldScore = (isNewRule ? Double.NEGATIVE_INFINITY : pathCosts
.getCount(unaryRule));
if (oldScore > newScore)
return;
if (isNewRule) {
CollectionUtils.addToValueList(closedUnaryRulesByChild,
unaryRule.getChild(), unaryRule);
CollectionUtils.addToValueList(closedUnaryRulesByParent,
unaryRule.getParent(), unaryRule);
}
pathCosts.setCount(unaryRule, newScore);
intermediateStates.put(unaryRule, intermediateState);
}
示例2: main
import edu.berkeley.nlp.util.Counter; //导入方法依赖的package包/类
public static void main(String[] args) {
Counter<String> counter = new Counter<String>();
System.out.println(counter);
counter.incrementCount("planets", 7);
System.out.println(counter);
counter.incrementCount("planets", 1);
System.out.println(counter);
counter.setCount("suns", 1);
System.out.println(counter);
counter.setCount("aliens", 0);
System.out.println(counter);
System.out.println(counter.toString(2));
System.out.println("Total: " + counter.totalCount());
}
示例3: logProbabiltyArrayToProbabiltyCounter
import edu.berkeley.nlp.util.Counter; //导入方法依赖的package包/类
private Counter<L> logProbabiltyArrayToProbabiltyCounter(
double[] logProbabilities) {
Counter<L> probabiltyCounter = new Counter<L>();
for (int labelIndex = 0; labelIndex < logProbabilities.length; labelIndex++) {
double logProbability = logProbabilities[labelIndex];
double probability = Math.exp(logProbability);
L label = encoding.getLabel(labelIndex);
probabiltyCounter.setCount(label, probability);
}
return probabiltyCounter;
}
示例4: getWeightsCounter
import edu.berkeley.nlp.util.Counter; //导入方法依赖的package包/类
public Counter<String> getWeightsCounter(double[] weights) {
Counter<String> counts = new Counter<String>();
for (L label : labels) {
for (int i = 0; i < featManager.getNumFeatures(); ++i) {
Feature feat = featManager.getFeature(i);
int index = getWeightIndex(feat, label);
String labelFeat = String.format("%s && %s", label, feat);
counts.setCount(labelFeat, weights[index]);
}
}
return counts;
}
示例5: getFeatures
import edu.berkeley.nlp.util.Counter; //导入方法依赖的package包/类
private Counter<Feature> getFeatures(I input) {
Counter<String> strCounts = featureExtractor.extractFeatures(input);
Counter<Feature> featCounts = new Counter<Feature>();
for (String f : strCounts.keySet()) {
double count = strCounts.getCount(f);
Feature feat = featureManager.getFeature(f);
featCounts.setCount(feat, count);
}
return featCounts;
}
示例6: examineWeights
import edu.berkeley.nlp.util.Counter; //导入方法依赖的package包/类
private String examineWeights() {
Counter<Feature> counts = new Counter<Feature>();
for (int i = 0; i < weights.length; ++i) {
Feature feat = featureManager.getFeature(i);
counts.setCount(feat, weights[i]);
}
return counts.toString();
}