本文整理汇总了Java中edu.berkeley.nlp.util.PriorityQueue.getPriority方法的典型用法代码示例。如果您正苦于以下问题:Java PriorityQueue.getPriority方法的具体用法?Java PriorityQueue.getPriority怎么用?Java PriorityQueue.getPriority使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.berkeley.nlp.util.PriorityQueue
的用法示例。
在下文中一共展示了PriorityQueue.getPriority方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTopKLabelSequencesAndScores
import edu.berkeley.nlp.util.PriorityQueue; //导入方法依赖的package包/类
public List<Pair<List<L>, Double>> getTopKLabelSequencesAndScores(
InstanceSequence<V, E, L> s, int k) {
Pair<int[][][][], double[][][]> chart = inf.getKBestChartAndBacktrace(
s, w, k);
List<Pair<List<L>, Double>> sentences = new ArrayList<Pair<List<L>, Double>>(
k);
int n = s.getSequenceLength();
PriorityQueue<Pair<Integer, Integer>> rankedScores = buildRankedScoreQueue(chart
.getSecond()[n - 1]);
for (int i = 0; i < k && rankedScores.hasNext(); i++) {
double score = rankedScores.getPriority();
Pair<Integer, Integer> chain = rankedScores.next();
sentences.add(Pair.makePair(
rebuildChain(chart.getFirst(), chain.getFirst(),
chain.getSecond()), score));
}
return sentences;
}
示例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);
}