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


Java PriorityQueue.add方法代码示例

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


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

示例1: buildRankedScoreQueue

import edu.berkeley.nlp.util.PriorityQueue; //导入方法依赖的package包/类
private PriorityQueue<Pair<Integer, Integer>> buildRankedScoreQueue(
		double[][] scores) {
	PriorityQueue<Pair<Integer, Integer>> pq = new PriorityQueue<Pair<Integer, Integer>>();
	for (int l = 0; l < scores.length; l++) {
		for (int c = 0; c < scores[l].length; c++) {
			pq.add(Pair.makePair(l, c), scores[l][c]);
		}
	}
	return pq;
}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:11,代码来源:ChainCRFTagger.java

示例2: getKBestChartAndBacktrace

import edu.berkeley.nlp.util.PriorityQueue; //导入方法依赖的package包/类
public Pair<int[][][][], double[][][]> getKBestChartAndBacktrace(
		InstanceSequence<V, E, L> sequence, double[] w, int k) {
	int n = sequence.getSequenceLength();
	int numLabels = encoding.getNumLabels();
	int[][][][] bestLabels = new int[n][numLabels][][];
	double[][][] bestScores = new double[n][numLabels][];
	double[] startScores = scoreCalculator.getLinearVertexScores(sequence,
			0, w);
	for (int l = 0; l < numLabels; l++) {
		bestScores[0][l] = new double[] { startScores[l] };
		bestLabels[0][l] = new int[][] { new int[] { -1, 0 } };
	}
	for (int i = 1; i < n; i++) {
		double[][] scoreMatrix = scoreCalculator.getLinearScoreMatrix(
				sequence, i, w);
		for (int l = 0; l < numLabels; l++) {
			PriorityQueue<Pair<Integer, Integer>> pq = new PriorityQueue<Pair<Integer, Integer>>();
			for (int pl = 0; pl < numLabels; pl++) {
				double edgeScore = scoreMatrix[pl][l];
				for (int c = 0; c < bestScores[i - 1][pl].length; c++) {
					double totalScore = edgeScore
							+ bestScores[i - 1][pl][c];
					pq.add(Pair.makePair(pl, c), totalScore);
				}
			}
			int cands = Math.min(k, pq.size());
			bestScores[i][l] = new double[cands];
			bestLabels[i][l] = new int[cands][2];
			for (int c = 0; c < cands; c++) {
				bestScores[i][l][c] = pq.getPriority();
				Pair<Integer, Integer> backtrace = pq.next();
				bestLabels[i][l][c][0] = backtrace.getFirst();
				bestLabels[i][l][c][1] = backtrace.getSecond();
			}
		}
	}
	return Pair.makePair(bestLabels, bestScores);
}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:39,代码来源:Inference.java

示例3: printMergingStatistics

import edu.berkeley.nlp.util.PriorityQueue; //导入方法依赖的package包/类
/**
 * @param grammar
 * @param newGrammar
 */
public static void printMergingStatistics(Grammar grammar,
		Grammar newGrammar) {
	PriorityQueue<String> lexiconStates = new PriorityQueue<String>();
	PriorityQueue<String> grammarStates = new PriorityQueue<String>();
	short[] numSubStatesArray = grammar.numSubStates;
	short[] newNumSubStatesArray = newGrammar.numSubStates;
	Numberer tagNumberer = grammar.tagNumberer;
	for (short state = 0; state < numSubStatesArray.length; state++) {
		System.out.print("\nState " + tagNumberer.object(state) + " had "
				+ numSubStatesArray[state] + " substates and now has "
				+ newNumSubStatesArray[state] + ".");
		if (!grammar.isGrammarTag(state)) {
			lexiconStates.add((String) tagNumberer.object(state),
					newNumSubStatesArray[state]);
		} else {
			grammarStates.add((String) tagNumberer.object(state),
					newNumSubStatesArray[state]);
		}
	}

	System.out.print("\n");
	System.out.println("Lexicon: " + lexiconStates.toString());
	System.out.println("Grammar: " + grammarStates.toString());

	// System.out.println("after merging, we have split trees:");
	// for (int i=0; i<grammar.numStates; i++) {
	// System.out.println(grammar.splitTrees[i]);
	// }

}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:35,代码来源:GrammarMerger.java


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