本文整理汇总了Java中edu.stanford.nlp.semgraph.SemanticGraph.getEdge方法的典型用法代码示例。如果您正苦于以下问题:Java SemanticGraph.getEdge方法的具体用法?Java SemanticGraph.getEdge怎么用?Java SemanticGraph.getEdge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.semgraph.SemanticGraph
的用法示例。
在下文中一共展示了SemanticGraph.getEdge方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSubgraph
import edu.stanford.nlp.semgraph.SemanticGraph; //导入方法依赖的package包/类
private static SemanticGraph getSubgraph(ObjectArrayList<TypedDependency> tds, SemanticGraph sg, IndexedWord parent,
SemanticGraphEdge e, int maxPathLength, ObjectArrayList<IndexedWord> words){
Set<IndexedWord> children = sg.getChildren(parent);
for (IndexedWord child: children){
if (((sg.getShortestDirectedPathEdges(sg.getFirstRoot(), child)).size() <= maxPathLength) &&
words.contains(child)){
e = sg.getEdge(parent, child);
tds.add(new TypedDependency(e.getRelation(), parent, child));
if (sg.hasChildren(child))
getSubgraph(tds, sg, child, e, maxPathLength, words);
} // else break;
}
TreeGraphNode rootTGN = new TreeGraphNode(new CoreLabel(parent));
EnglishGrammaticalStructure gs = new EnglishGrammaticalStructure(tds, rootTGN);
return SemanticGraphFactory.generateUncollapsedDependencies(gs);
}
示例2: listOfIndexedWordsToParentEdges
import edu.stanford.nlp.semgraph.SemanticGraph; //导入方法依赖的package包/类
/**
*
*/
public static ObjectArrayList<SemanticGraphEdge> listOfIndexedWordsToParentEdges(SemanticGraph semanticGraph, ObjectArrayList<IndexedWord> wordList) {
ObjectArrayList<SemanticGraphEdge> result = new ObjectArrayList<>();
for (IndexedWord word: wordList) {
if (!semanticGraph.containsVertex(word)) continue;
SemanticGraphEdge edge = semanticGraph.getEdge(semanticGraph.getParent(word), word);
result.add(edge);
}
return result;
}
示例3: isPrepositionalPhrase
import edu.stanford.nlp.semgraph.SemanticGraph; //导入方法依赖的package包/类
/** Checks whether this constituent is a prepositional phrase (i.e., starts with a preposition). */
public boolean isPrepositionalPhrase(SemanticGraph sentSemanticGraph) { //This is a mess, find other way of fixing. This is purelly heuristic.
//It needs to know the semantic graph for the sentence after this is fixed the member variable sentSemanticGraph
//can be removed
List<IndexedWord> parents = semanticGraph.getParentList(root); //This is not the cleanest way semantics messed up.
//specially with the rel we cannot just check if
//the head is a preposition
//(return root.tag().equals("IN")) because the
//parser some times includes a preposition in the
//verbal phrase "He is about to win"
for(IndexedWord parent: parents) {
SemanticGraphEdge edge = semanticGraph.getEdge(parent, root);
if(DpUtils.isRel(edge))
return true;
if(DpUtils.isAnyPrep(edge)) {
List<IndexedWord> ancestors = sentSemanticGraph.getParentList(parent);
for(IndexedWord ancestor: ancestors) {
SemanticGraphEdge ed = sentSemanticGraph.getEdge(ancestor, parent);
if(DpUtils.isRcmod(ed))
return true;
}
}
}
return false;
//return root.tag().equals("IN");
}