private IntPair getNPSpanOld(IndexedWord headword, SemanticGraph dep, List<CoreLabel> sent) { IndexedWord cop = dep.getChildWithReln(headword, UniversalEnglishGrammaticalRelations.COPULA); Pair<IndexedWord, IndexedWord> leftRight = SemanticGraphUtils.leftRightMostChildVertices(headword, dep); // headword can be first or last word int beginIdx = Math.min(headword.index()-1, leftRight.first.index()-1); int endIdx = Math.max(headword.index()-1, leftRight.second.index()-1); // no copula relation if(cop==null) return new IntPair(beginIdx, endIdx); // if we have copula relation List<IndexedWord> children = dep.getChildList(headword); int copIdx = children.indexOf(cop); if(copIdx+1 < children.size()) { beginIdx = Math.min(headword.index()-1, SemanticGraphUtils.leftMostChildVertice(children.get(copIdx+1), dep).index()-1); } else { beginIdx = headword.index()-1; } return new IntPair(beginIdx, endIdx); }
if(c.index() < conjChild.index()) conjChild = c; IndexedWord left = SemanticGraphUtils.leftMostChildVertice(conjChild, dep); for(int endIdxFirstElement = left.index()-1 ; endIdxFirstElement > beginIdx ; endIdxFirstElement--) { if(!sent.get(endIdxFirstElement-1).tag().matches("CC|,")) {
/** * TODO: figure out how to specify where in the sentence this node goes. * TODO: determine if we should be copying an IndexedWord, or working just with a FeatureLabel. * TODO: bombproof if this gov, dep, and reln already exist. */ @Override public void evaluate(SemanticGraph sg, SemgrexMatcher sm) { IndexedWord govNode = sm.getNode(govNodeName); IndexedWord newNode = new IndexedWord(newNodePrototype); int newIndex = SemanticGraphUtils.leftMostChildVertice(govNode, sg).index(); // cheap En-specific hack for placing copula (beginning of governing phrase) newNode.setDocID(govNode.docID()); newNode.setIndex(newIndex); newNode.setSentIndex(govNode.sentIndex()); sg.addVertex(newNode); sg.addEdge(govNode, newNode, relation, weight,false); }
private IntPair getNPSpanOld(IndexedWord headword, SemanticGraph dep, List<CoreLabel> sent) { IndexedWord cop = dep.getChildWithReln(headword, UniversalEnglishGrammaticalRelations.COPULA); Pair<IndexedWord, IndexedWord> leftRight = SemanticGraphUtils.leftRightMostChildVertices(headword, dep); // headword can be first or last word int beginIdx = Math.min(headword.index()-1, leftRight.first.index()-1); int endIdx = Math.max(headword.index()-1, leftRight.second.index()-1); // no copula relation if(cop==null) return new IntPair(beginIdx, endIdx); // if we have copula relation List<IndexedWord> children = dep.getChildList(headword); int copIdx = children.indexOf(cop); if(copIdx+1 < children.size()) { beginIdx = Math.min(headword.index()-1, SemanticGraphUtils.leftMostChildVertice(children.get(copIdx+1), dep).index()-1); } else { beginIdx = headword.index()-1; } return new IntPair(beginIdx, endIdx); }
if(c.index() < conjChild.index()) conjChild = c; IndexedWord left = SemanticGraphUtils.leftMostChildVertice(conjChild, dep); for(int endIdxFirstElement = left.index()-1 ; endIdxFirstElement > beginIdx ; endIdxFirstElement--) { if(!sent.get(endIdxFirstElement-1).tag().matches("CC|,")) {