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


Java SemanticGraph.getEdge方法代码示例

本文整理汇总了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);
}
 
开发者ID:gkiril,项目名称:minie,代码行数:19,代码来源:CoreNLPUtils.java

示例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;
}
 
开发者ID:gkiril,项目名称:minie,代码行数:13,代码来源:CoreNLPUtils.java

示例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");
}
 
开发者ID:gkiril,项目名称:minie,代码行数:29,代码来源:IndexedConstituent.java


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