本文整理汇总了Java中edu.stanford.nlp.util.Generics.newLinkedList方法的典型用法代码示例。如果您正苦于以下问题:Java Generics.newLinkedList方法的具体用法?Java Generics.newLinkedList怎么用?Java Generics.newLinkedList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.util.Generics
的用法示例。
在下文中一共展示了Generics.newLinkedList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toEnUncollapsedSentenceString
import edu.stanford.nlp.util.Generics; //导入方法依赖的package包/类
/**
* Similar to <code>toRecoveredString</code>, but will fill in words that were
* collapsed into relations (i.e. prep_for --> 'for'). Mostly to deal with
* collapsed dependency trees.
*
* TODO: consider merging with toRecoveredString() NOTE: assumptions currently
* are for English. NOTE: currently takes immediate successors to current word
* and expands them. This assumption may not be valid for other conditions or
* languages?
*/
public String toEnUncollapsedSentenceString() {
List<IndexedWord> uncompressedList = Generics.newLinkedList(vertexSet());
List<Pair<String, IndexedWord>> specifics = Generics.newArrayList();
// Collect the specific relations and the governed nodes, and then process
// them one by one,
// to avoid concurrent modification exceptions.
for (IndexedWord word : vertexSet()) {
for (SemanticGraphEdge edge : getIncomingEdgesSorted(word)) {
GrammaticalRelation relation = edge.getRelation();
// Extract the specific: need to account for possiblity that relation
// can
// be a String or GrammaticalRelation (how did it happen this way?)
String specific = relation.getSpecific();
if (specific == null) {
if (edge.getRelation().equals(EnglishGrammaticalRelations.AGENT)) {
specific = "by";
}
}
// Insert the specific at the leftmost token that is not governed by
// this node.
if (specific != null) {
Pair<String, IndexedWord> specPair = new Pair<String, IndexedWord>(specific, word);
specifics.add(specPair);
}
}
}
for (Pair<String, IndexedWord> tuple : specifics) {
insertSpecificIntoList(tuple.first(), tuple.second(), uncompressedList);
}
return StringUtils.join(uncompressedList, " ");
}