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


Java PriorityQueue.size方法代码示例

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


在下文中一共展示了PriorityQueue.size方法的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>");
}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:54,代码来源:GrammarStatistics.java

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


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