本文整理汇总了Java中edu.berkeley.nlp.syntax.Trees.PennTreeReader方法的典型用法代码示例。如果您正苦于以下问题:Java Trees.PennTreeReader方法的具体用法?Java Trees.PennTreeReader怎么用?Java Trees.PennTreeReader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.berkeley.nlp.syntax.Trees
的用法示例。
在下文中一共展示了Trees.PennTreeReader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import edu.berkeley.nlp.syntax.Trees; //导入方法依赖的package包/类
public static void main(String args[]) {
// test the binarization
Trees.PennTreeReader reader = new Trees.PennTreeReader(
new StringReader(
"((S (NP (DT the) (JJ quick) (JJ (AA (BB (CC brown)))) (NN fox)) (VP (VBD jumped) (PP (IN over) (NP (DT the) (JJ lazy) (NN dog)))) (. .)))"));
Tree<String> tree = reader.next();
System.out.println("tree");
System.out.println(Trees.PennTreeRenderer.render(tree));
for (Binarization binarization : Binarization.values()) {
System.out.println("binarization type " + binarization.name());
// print the binarization
try {
Tree<String> binarizedTree = binarizeTree(tree, binarization);
System.out
.println(Trees.PennTreeRenderer.render(binarizedTree));
System.out.println("unbinarized");
Tree<String> unBinarizedTree = unAnnotateTree(binarizedTree,
false);
System.out.println(Trees.PennTreeRenderer
.render(unBinarizedTree));
System.out.println("------------");
} catch (Error e) {
System.out.println("binarization not implemented");
}
}
}
示例2: main
import edu.berkeley.nlp.syntax.Trees; //导入方法依赖的package包/类
/**
* Go through trees and determine their heads and print them. Just for
* debuggin'. <br>
* Usage: <code>
* java edu.stanford.nlp.trees.CollinsHeadFinder treebankFilePath
* </code>
*
* @param args
* The treebankFilePath
*/
public static void main(String[] args) {
Trees.PennTreeReader reader = new Trees.PennTreeReader(
new StringReader(
"((S (NP (DT the) (JJ quick) (JJ (AA (BB (CC brown)))) (NN fox)) (VP (VBD jumped) (PP (IN over) (NP (DT the) (JJ lazy) (NN dog)))) (. .)))"));
Tree<String> tree = reader.next();
System.out.println("tree " + tree);
CollinsHeadFinder headFinder = new CollinsHeadFinder();
while (!tree.isLeaf()) {
Tree<String> head = headFinder.determineHead(tree);
System.out.println("head " + head);
tree = head;
}
}
示例3: advance
import edu.berkeley.nlp.syntax.Trees; //导入方法依赖的package包/类
private void advance() {
nextTreeIterator = null;
while (nextTreeIterator == null && fileIterator.hasNext()) {
try {
File file = fileIterator.next();
nextTreeIterator = new Trees.PennTreeReader(
new BufferedReader(new FileReader(file)));
} catch (FileNotFoundException e) {
}
}
}