当前位置: 首页>>代码示例>>Java>>正文


Java SemanticGraph.removeEdge方法代码示例

本文整理汇总了Java中edu.stanford.nlp.semgraph.SemanticGraph.removeEdge方法的典型用法代码示例。如果您正苦于以下问题:Java SemanticGraph.removeEdge方法的具体用法?Java SemanticGraph.removeEdge怎么用?Java SemanticGraph.removeEdge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在edu.stanford.nlp.semgraph.SemanticGraph的用法示例。


在下文中一共展示了SemanticGraph.removeEdge方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeEdges

import edu.stanford.nlp.semgraph.SemanticGraph; //导入方法依赖的package包/类
/** Removes some edges from the given semantic graph.
 * 
 * This method traverses the semantic graph starting from the given root. An edge is removed if
 * (1) its child appears in <code>excludeVertexes</code>, (2) its relation appears in
 * <code>excludeRelations</code>, or (3) the edge has the root as parent and its relation
 * appears in <code>excludeRelationsTop</code>. */
public static void removeEdges(SemanticGraph graph, IndexedWord root, Collection<IndexedWord> excludeVertexes,
        Collection<GrammaticalRelation> excludeRelations, Collection<GrammaticalRelation> excludeRelationsTop) {
    if (!excludeVertexes.contains(root)) {
        Set<SemanticGraphEdge> edgesToRemove = new HashSet<SemanticGraphEdge>();
        subgraph(graph, root, excludeVertexes, excludeRelations, excludeRelationsTop, edgesToRemove, 0);
        for (SemanticGraphEdge edge : edgesToRemove) {
            graph.removeEdge(edge);
        }
    }
}
 
开发者ID:gkiril,项目名称:minie,代码行数:17,代码来源:DpUtils.java

示例2: disconectClauses

import edu.stanford.nlp.semgraph.SemanticGraph; //导入方法依赖的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);
        }
    }
}
 
开发者ID:gkiril,项目名称:minie,代码行数:16,代码来源:DpUtils.java

示例3: removePunctEdges

import edu.stanford.nlp.semgraph.SemanticGraph; //导入方法依赖的package包/类
/**
 * Remove the 'punct' edges
 * @param g -> Semantic graph gotten from the dependency parse 
 */
public static void removePunctEdges(SemanticGraph semanticGraph){
    for (SemanticGraphEdge edge : new ArrayList<>(semanticGraph.edgeListSorted())){
        if (EnglishGrammaticalRelations.PUNCTUATION.equals(edge.getRelation())){
            semanticGraph.removeEdge(edge);
        }
    }
}
 
开发者ID:gkiril,项目名称:minie,代码行数:12,代码来源:DpUtils.java

示例4: createPossConstituent

import edu.stanford.nlp.semgraph.SemanticGraph; //导入方法依赖的package包/类
/** Creates a constituent for a possessive relative clause
 * @param semanticGraph The semantic graph
 * @param poss The edge referring to the possessive relation
 * @param rcmod The relative clause modifier of the relation
 * @param constGovernor The root of the constituent
 * @param type The type of the constituent
*/
private static Constituent createPossConstituent(SemanticGraph semanticGraph,
        SemanticGraphEdge poss, SemanticGraphEdge rcmod, IndexedWord constGovernor, Type type) {
    SemanticGraph newSemanticGraph = new SemanticGraph(semanticGraph);
    double weight = poss.getWeight();
    newSemanticGraph.addEdge(poss.getGovernor(), rcmod.getGovernor(), EnglishGrammaticalRelations.POSSESSION_MODIFIER, 
                             weight, false);
    Set<IndexedWord> exclude = DpUtils.exclude(newSemanticGraph, EXCLUDE_RELATIONS_COMPLEMENT, rcmod.getGovernor());
    newSemanticGraph.removeEdge(poss);
    newSemanticGraph.removeEdge(rcmod);
    return new IndexedConstituent(newSemanticGraph, constGovernor, Collections.<IndexedWord> emptySet(), exclude, type);
}
 
开发者ID:gkiril,项目名称:minie,代码行数:19,代码来源:ClauseDetector.java


注:本文中的edu.stanford.nlp.semgraph.SemanticGraph.removeEdge方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。