本文整理汇总了Java中edu.berkeley.nlp.util.Iterators类的典型用法代码示例。如果您正苦于以下问题:Java Iterators类的具体用法?Java Iterators怎么用?Java Iterators使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Iterators类属于edu.berkeley.nlp.util包,在下文中一共展示了Iterators类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import edu.berkeley.nlp.util.Iterators; //导入依赖的package包/类
public static void main(String argv[]) throws FileNotFoundException {
BufferedReader inputData = (argv.length == 0) ? new BufferedReader(
new InputStreamReader(System.in)) : new BufferedReader(
new InputStreamReader(new FileInputStream(argv[0])));
for (Tree<String> tree : Iterators.able(new Trees.PennTreeReader(
inputData))) {
tree = new Trees.EmptyNodeStripper().transformTree(tree);
System.out.println(StrUtils.join(tree.getYield()));
}
}
示例2: main
import edu.berkeley.nlp.util.Iterators; //导入依赖的package包/类
public static void main(String[] argv) {
PTBLineLexer tokenizer = new PTBLineLexer();
try {
for (String line : Iterators.able(IOUtils.lineIterator(argv[0]))) {
final List<String> tokenizeLine = tokenizer.tokenizeLine(line);
if (tokenizeLine.get(tokenizeLine.size() - 1) == null)
tokenizeLine.remove(tokenizeLine.size() - 1);
System.out.println(StringUtils.join(tokenizeLine));
}
} catch (IOException e) {
// TODO Auto-generated catch block
throw new RuntimeException(e);
}
}