當前位置: 首頁>>代碼示例>>Java>>正文


Java StateSetTreeList.size方法代碼示例

本文整理匯總了Java中edu.berkeley.nlp.PCFGLA.StateSetTreeList.size方法的典型用法代碼示例。如果您正苦於以下問題:Java StateSetTreeList.size方法的具體用法?Java StateSetTreeList.size怎麽用?Java StateSetTreeList.size使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在edu.berkeley.nlp.PCFGLA.StateSetTreeList的用法示例。


在下文中一共展示了StateSetTreeList.size方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ParsingObjectiveFunction

import edu.berkeley.nlp.PCFGLA.StateSetTreeList; //導入方法依賴的package包/類
public ParsingObjectiveFunction(Linearizer linearizer,
		StateSetTreeList trainTrees, double sigma, int regularization,
		String consName, int nProc, String outName,
		boolean doNotProjectConstraints, boolean combinedLexicon) {
	this.sigma = sigma;
	this.myRegularization = regularization;
	this.grammar = linearizer.getGrammar();// .copyGrammar();
	this.lexicon = linearizer.getLexicon();// .copyLexicon();
	this.spanPredictor = linearizer.getSpanPredictor();
	this.linearizer = linearizer;
	this.outFileName = outName;
	this.dimension = linearizer.dimension();

	nGrammarWeights = linearizer.getNGrammarWeights();
	nLexiconWeights = linearizer.getNLexiconWeights();
	nSpanWeights = linearizer.getNSpanWeights();

	if (spanPredictor != null)
		this.spanGoldCounts = spanPredictor
				.countGoldSpanFeatures(trainTrees);

	int nTreesPerBlock = trainTrees.size() / nProc;
	this.consBaseName = consName;
	boolean[][][][][] tmp = edu.berkeley.nlp.PCFGLA.ParserConstrainer
			.loadData(consName + "-0.data");
	if (tmp != null)
		nTreesPerBlock = tmp.length;

	// split the trees into chunks
	this.nProcesses = nProc;
	trainingTrees = new StateSetTreeList[nProcesses];
	// allowedStates = new ArrayList[nProcesses];
	for (int i = 0; i < nProcesses; i++) {
		trainingTrees[i] = new StateSetTreeList();
		// allowedStates[i] = new ArrayList<boolean[][][][]>();
	}
	int block = -1;
	int inBlock = 0;
	for (int i = 0; i < trainTrees.size(); i++) {
		if (i % nTreesPerBlock == 0) {
			block++;
			// System.out.println(inBlock);
			inBlock = 0;
		}
		trainingTrees[block % nProcesses].add(trainTrees.get(i));
		inBlock++;
		// if (cons!=null)
		// allowedStates[i%nProcesses].add(ArrayUtil.clone(cons[i]));
	}
	for (int i = 0; i < nProcesses; i++) {
		System.out.println("Process " + i + " has "
				+ trainingTrees[i].size() + " trees.");
	}
	trainTrees = null;
	pool = Executors.newFixedThreadPool(nProcesses);// CachedThreadPool();

	tasks = new Calculator[nProcesses];
	for (int i = 0; i < nProcesses; i++) {
		tasks[i] = newCalculator(doNotProjectConstraints, i);
	}

	this.bestObjectiveSoFar = Double.POSITIVE_INFINITY;
}
 
開發者ID:text-machine-lab,項目名稱:CliRel,代碼行數:64,代碼來源:ParsingObjectiveFunction.java

示例2: ConditionalMerger

import edu.berkeley.nlp.PCFGLA.StateSetTreeList; //導入方法依賴的package包/類
/**
 * @param processes
 * @param consBaseName
 * @param trainingTrees
 */
public ConditionalMerger(int processes, String consBaseName,
		StateSetTreeList trainTrees, Grammar gr, Lexicon lex,
		double mergingPercentage, String outFileName) {
	this.nProcesses = processes;
	this.consBaseName = consBaseName;
	this.grammar = gr;// .copyGrammar();
	this.lexicon = lex;// .copyLexicon();
	this.mergingPercentage = mergingPercentage;
	this.outFileName = outFileName;

	int nTreesPerBlock = trainTrees.size() / processes;
	this.consBaseName = consBaseName;
	boolean[][][][][] tmp = edu.berkeley.nlp.PCFGLA.ParserConstrainer
			.loadData(consBaseName + "-0.data");
	if (tmp != null)
		nTreesPerBlock = tmp.length;

	// first compute the generative merging criterion
	mergeWeights = GrammarMerger.computeMergeWeights(grammar, lexicon,
			trainTrees);
	double[][][] deltas = GrammarMerger.computeDeltas(grammar, lexicon,
			mergeWeights, trainTrees);
	boolean[][][] mergeThesePairs = GrammarMerger.determineMergePairs(
			deltas, false, mergingPercentage, grammar);
	Grammar tmpGrammar = grammar.copyGrammar(true);
	Lexicon tmpLexicon = lexicon.copyLexicon();
	tmpGrammar = GrammarMerger.doTheMerges(tmpGrammar, tmpLexicon,
			mergeThesePairs, mergeWeights);
	System.out.println("Generative merging criterion gives:");
	GrammarMerger.printMergingStatistics(grammar, tmpGrammar);
	mergeWeights = GrammarMerger.computeMergeWeights(grammar, lexicon,
			trainTrees);

	// split the trees into chunks
	trainingTrees = new StateSetTreeList[nProcesses];
	for (int i = 0; i < nProcesses; i++) {
		trainingTrees[i] = new StateSetTreeList();
	}
	int block = -1;
	int inBlock = 0;
	for (int i = 0; i < trainTrees.size(); i++) {
		if (i % nTreesPerBlock == 0) {
			block++;
			System.out.println(inBlock);
			inBlock = 0;
		}
		trainingTrees[block % nProcesses].add(trainTrees.get(i));
		inBlock++;
	}
	trainTrees = null;
	pool = Executors.newFixedThreadPool(nProcesses);// CachedThreadPool();

	tasks = new Merger[nProcesses];
	for (int i = 0; i < nProcesses; i++) {
		tasks[i] = new Merger(trainingTrees[i], consBaseName, i, grammar,
				lexicon, mergeWeights);
	}

}
 
開發者ID:text-machine-lab,項目名稱:CliRel,代碼行數:65,代碼來源:ConditionalMerger.java


注:本文中的edu.berkeley.nlp.PCFGLA.StateSetTreeList.size方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。