本文整理匯總了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
}