本文整理汇总了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;
}
示例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()));
}