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


Java Counter.setCount方法代码示例

本文整理汇总了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);
}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:24,代码来源:UnaryClosureComputer.java

示例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());
}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:15,代码来源:BinaryCounterTable.java

示例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;
}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:12,代码来源:MaximumEntropyClassifier.java

示例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;
}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:13,代码来源:LabelFeatureWeightsManager.java

示例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;
}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:11,代码来源:LinearRegression.java

示例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();
}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:9,代码来源:LinearRegression.java


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