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


Java Trees.FunctionLabelRetainingTreeNormalizer方法代码示例

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


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

示例1: readTrees

import edu.berkeley.nlp.syntax.Trees; //导入方法依赖的package包/类
public static List<Tree<String>> readTrees(String basePath, int low,
		int high, Charset charset) throws Exception {
	Collection<Tree<String>> trees = PennTreebankReader.readTrees(basePath,
			low, high, charset);
	// System.out.println("in readTrees");
	// normalize trees
	Trees.TreeTransformer<String> treeTransformer = (keepFunctionLabels) ? new Trees.FunctionLabelRetainingTreeNormalizer()
			: new Trees.StandardTreeNormalizer();
	List<Tree<String>> normalizedTreeList = new ArrayList<Tree<String>>();
	for (Tree<String> tree : trees) {
		Tree<String> normalizedTree = treeTransformer.transformTree(tree);
		normalizedTreeList.add(normalizedTree);
	}
	if (normalizedTreeList.size() == 0) {
		throw new Exception("failed to load any trees at " + basePath
				+ " from " + low + " to " + high);
	}
	return normalizedTreeList;
}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:20,代码来源:Corpus.java

示例2: loadSingleFile

import edu.berkeley.nlp.syntax.Trees; //导入方法依赖的package包/类
private void loadSingleFile(String path) throws Exception {
	System.out.print("Loading trees from single file...");
	InputStreamReader inputData = new InputStreamReader(
			new FileInputStream(path), "UTF-8");
	PennTreeReader treeReader = new PennTreeReader(inputData);

	while (treeReader.hasNext()) {
		trainTrees.add(treeReader.next());
	}

	Trees.TreeTransformer<String> treeTransformer = (keepFunctionLabels) ? new Trees.FunctionLabelRetainingTreeNormalizer()
			: new Trees.StandardTreeNormalizer();
	ArrayList<Tree<String>> normalizedTreeList = new ArrayList<Tree<String>>();
	for (Tree<String> tree : trainTrees) {
		Tree<String> normalizedTree = treeTransformer.transformTree(tree);
		normalizedTreeList.add(normalizedTree);
	}
	if (normalizedTreeList.size() == 0) {
		throw new Exception("failed to load any trees at " + path);
	}
	trainTrees = normalizedTreeList;

	devTestTrees = trainTrees;
	System.out.println("done");

	// trainTrees.addAll(readTrees(path,-1,
	// Integer.MAX_VALUE,Charset.defaultCharset()));
}
 
开发者ID:text-machine-lab,项目名称:CliRel,代码行数:29,代码来源:Corpus.java


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