本文整理汇总了Java中edu.stanford.nlp.semgraph.SemanticGraphEdge.getDependent方法的典型用法代码示例。如果您正苦于以下问题:Java SemanticGraphEdge.getDependent方法的具体用法?Java SemanticGraphEdge.getDependent怎么用?Java SemanticGraphEdge.getDependent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类edu.stanford.nlp.semgraph.SemanticGraphEdge
的用法示例。
在下文中一共展示了SemanticGraphEdge.getDependent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addParataxisClause
import edu.stanford.nlp.semgraph.SemanticGraphEdge; //导入方法依赖的package包/类
/** Creates a clause from a parataxis relation
* @param root Head of the parataxis relation
* @param parroot Dependent of the parataxis relation
* @param roots List of clause roots
*/
private static void addParataxisClause(ClausIE clausIE, IndexedWord root, IndexedWord parroot, List<IndexedWord> roots) {
Constituent verb = new IndexedConstituent(clausIE.getSemanticGraph(), parroot, Type.VERB);
List<SemanticGraphEdge> outedges = clausIE.getSemanticGraph().getOutEdgesSorted(parroot);
SemanticGraphEdge subject = DpUtils.findFirstOfRelationOrDescendent(outedges, EnglishGrammaticalRelations.SUBJECT);
if (subject != null) {
Constituent subjectConst = new IndexedConstituent(clausIE.getSemanticGraph(), subject.getDependent(),
Type.SUBJECT);
Constituent object = new IndexedConstituent(clausIE.getSemanticGraph(), root, Type.DOBJ);
((IndexedConstituent) object).excludedVertexes.add(parroot);
Clause clause = new Clause();
clause.setSubject(0);
clause.verb = 1;
clause.dobjects.add(2);
clause.constituents.add(subjectConst);
clause.constituents.add(verb);
clause.constituents.add(object);
clause.setType(Clause.Type.SVO);
clausIE.getClauses().add(clause);
roots.add(null);
}
}
示例2: subgraph
import edu.stanford.nlp.semgraph.SemanticGraphEdge; //导入方法依赖的package包/类
/** Implementation for
* {@link #removeEdges(SemanticGraph, IndexedWord, Collection, Collection, Collection)} */
private static int subgraph(SemanticGraph graph, IndexedWord root, Collection<IndexedWord> excludeVertexes,
Collection<GrammaticalRelation> excludeRelations, Collection<GrammaticalRelation> excludeRelationsTop,
Collection<SemanticGraphEdge> edgesToRemove, int counter) {
/* TODO: In some sentences there is infinite recursion. Dirty fix to stop it.
Example sentence:
"Policies on electronic tickets differ ''from airline to airline and airport to airport,'' said Ms. McInerney,
whose group is working with the airline industry on e-ticket policies and the matter of standardizing itineraries
and receipts, perhaps with a universal template to create more readily verifiable printouts that carry uniform
information like a ticket number that can be matched to an airline computer reservation."
*/
counter++;
if (counter > MAX_RECURSION_ITERATIONS){
return counter;
}
List<SemanticGraphEdge> edges = graph.getOutEdgesSorted(root);
for (SemanticGraphEdge e : edges) {
IndexedWord child = e.getDependent();
if (excludeVertexes.contains(child) || excludeRelations.contains(e.getRelation())
|| excludeRelationsTop.contains(e.getRelation())) {
edgesToRemove.add(graph.getEdge(root, child));
} else {
counter = subgraph(graph, child, excludeVertexes, excludeRelations,
Collections.<GrammaticalRelation> emptySet(), edgesToRemove, counter);
}
}
return counter;
}
示例3: disconectClauses
import edu.stanford.nlp.semgraph.SemanticGraphEdge; //导入方法依赖的package包/类
/** Disconnects independent clauses by removing the edge representing the coordinating conjunction */
public static void disconectClauses(SemanticGraph graph, Constituent constituent) {
List<SemanticGraphEdge> outedges = graph.getOutEdgesSorted(((IndexedConstituent) constituent).getRoot());
for (int i = 0; i < outedges.size(); i++) {
SemanticGraphEdge e = outedges.get(i);
if (DpUtils.isAnyConj(e)) {
IndexedWord child = e.getDependent();
List<SemanticGraphEdge> outNewRoot = graph.getOutEdgesSorted(child);
SemanticGraphEdge sub = DpUtils.findFirstOfRelationOrDescendent(outNewRoot,
EnglishGrammaticalRelations.SUBJECT);
if (sub != null)
graph.removeEdge(e);
}
}
}
示例4: getSubTreeEdgesHelper
import edu.stanford.nlp.semgraph.SemanticGraphEdge; //导入方法依赖的package包/类
private static void getSubTreeEdgesHelper(IndexedWord vertice, SemanticGraph sg, Set<SemanticGraphEdge> tabuEdges) {
for (SemanticGraphEdge edge : sg.outgoingEdgeIterable(vertice)) {
if (!tabuEdges.contains(edge)) {
IndexedWord dep = edge.getDependent();
tabuEdges.add(edge);
getSubTreeEdgesHelper(dep, sg, tabuEdges);
}
}
}