本文整理汇总了Java中edu.stanford.nlp.trees.Tree.yield方法的典型用法代码示例。如果您正苦于以下问题:Java Tree.yield方法的具体用法?Java Tree.yield怎么用?Java Tree.yield使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.trees.Tree
的用法示例。
在下文中一共展示了Tree.yield方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: FeatureNode
import edu.stanford.nlp.trees.Tree; //导入方法依赖的package包/类
FeatureNode(Tree node, IndexedWord hw) {
List<Label> yield = node.yield();
this.word = (IndexedWord) node.label();
this.hw = hw;
this.lm = (IndexedWord) yield.get(0);
this.rm = (IndexedWord) yield.get(yield.size() - 1);
this.dst = hw.index() - this.word.index();
}
示例2: readAlignments
import edu.stanford.nlp.trees.Tree; //导入方法依赖的package包/类
private void readAlignments()
{
if(new File(opts.sentencesFile).exists() && new File(opts.GHKMTreeFile).exists() && new File(opts.alignmentsFile).exists())
{
String[] sentences = Utils.readLines(opts.sentencesFile);
String[] trees = Utils.readLines(opts.GHKMTreeFile);
String[] alignments = Utils.readLines(opts.alignmentsFile);
int numOfNull = 0;
for(int i = 0; i < sentences.length; i++)
{
String[] words = sentences[i].split(" ");
try
{
Tree tree = Tree.valueOf(trees[i]);
if(tree != null)
{
List<CoreLabel> yield = new ArrayList<>();
tree.yield(yield);
String[] alignment = alignments[i].split(" ");
for(String token : alignment)
{
String[] yieldWord = token.split("-");
int yieldIndex = Integer.valueOf(yieldWord[0]);
int wordIndex = Integer.valueOf(yieldWord[1]);
if(yieldIndex < yield.size() && wordIndex < words.length)
{
String key = yield.get(yieldIndex).word();
updateVocabulary(key, words[wordIndex]);
//System.out.println(key + " " + words[wordIndex]);
}
} // for
} // if
else
{
numOfNull++;
}
}
catch(Exception ioe)
{
LogInfo.error("Error reading tree " + trees[i]);
}
} // for
Utils.logs("Num of null trees: " + numOfNull);
} // if
}