本文整理汇总了Java中edu.berkeley.nlp.util.PriorityQueue.peek方法的典型用法代码示例。如果您正苦于以下问题:Java PriorityQueue.peek方法的具体用法?Java PriorityQueue.peek怎么用?Java PriorityQueue.peek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.berkeley.nlp.util.PriorityQueue
的用法示例。
在下文中一共展示了PriorityQueue.peek方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: printGrammarStatistics
import edu.berkeley.nlp.util.PriorityQueue; //导入方法依赖的package包/类
/**
* @param columnOutput
* @param pData
* @param tagNumberer
* @param topN
* @param gs
* @param noContinueTags
*/
private static void printGrammarStatistics(boolean columnOutput,
ParserData pData, Numberer tagNumberer, int topN,
GrammarStatistics gs, Set<Short> noContinueTags) {
System.out.println("<a name=\"grammar\"><h1>Grammar</h1></a>");
System.out.println("<div id=\"grammar\">");
// print rule probabilities
for (short curTag : noContinueTags) {
int nSubStates = pData.numSubStatesArray[curTag];
ArrayList<SearchState>[] results = new ArrayList[nSubStates];
for (short i = 0; i < nSubStates; i++) {
// do heavy computation
PriorityQueue<SearchState> pq = gs
.getTopProductions(new FullState(curTag, i));
// convert pq to array
results[i] = new ArrayList<SearchState>(topN);
while (pq.size() != 0) {
pq.peek().score = Math.exp(pq.peek().score);
results[i].add(0, pq.next());
}
}
String[][] outputMatrix = new String[topN + 1][nSubStates];
String tagName = (String) tagNumberer.object(curTag);
for (int i = 0; i < nSubStates; i++) {
outputMatrix[0][i] = tagName + "-" + i;
}
for (int j = 0; j < topN; j++) {
for (int i = 0; i < nSubStates; i++) {
String o = "";
double p = -1;
if (results[i].size() > j) {
p = results[i].get(j).score;
String w = results[i].get(j).toString(tagNumberer);
o = f.format(p) + " " + w;
}
outputMatrix[j + 1][i] = o;
}
}
printRules("Grammar", "productions", columnOutput, outputMatrix);
}
System.out.println("</div>");
}
示例2: printParentRuleStatistics
import edu.berkeley.nlp.util.PriorityQueue; //导入方法依赖的package包/类
/**
* @param columnOutput
* @param pData
* @param tagNumberer
* @param topN
* @param gs
* @param noContinueTags
*/
private static void printParentRuleStatistics(boolean columnOutput,
ParserData pData, Numberer tagNumberer, int topN,
GrammarStatistics gs, Set<Short> noContinueTags,
double[] probState, double[][] probSubGivenState) {
System.out.println("<a name=\"parentrules\"><h1>Parent Rules</h1></a>");
// print rule probabilities
for (short curTag : noContinueTags) {
int nSubStates = pData.numSubStatesArray[curTag];
ArrayList<SearchState>[] results = new ArrayList[nSubStates];
for (short i = 0; i < nSubStates; i++) {
// do heavy computation
PriorityQueue<SearchState> pq = gs.getTopParentRuleProductions(
new FullState(curTag, i), probState, probSubGivenState);
// convert pq to array
results[i] = new ArrayList<SearchState>(topN);
while (pq.size() != 0) {
pq.peek().score = Math.exp(pq.peek().score);
results[i].add(0, pq.next());
}
}
String[][] outputMatrix = new String[topN + 1][nSubStates];
String tagName = (String) tagNumberer.object(curTag);
for (int i = 0; i < nSubStates; i++) {
outputMatrix[0][i] = tagName + "-" + i;
}
for (int j = 0; j < topN; j++) {
for (int i = 0; i < nSubStates; i++) {
String o = "";
double p = -1;
if (results[i].size() > j) {
p = results[i].get(j).score;
String w = results[i].get(j).toString(tagNumberer);
o = f.format(p) + " " + w;
}
outputMatrix[j + 1][i] = o;
}
}
printRules("Parent Rules", "parentrules", columnOutput,
outputMatrix);
}
}