Pair<IndexedWord, IndexedWord> firstChildLeftRight = SemanticGraphUtils.leftRightMostChildVertices(insideNP.get(0), dep); Pair<IndexedWord, IndexedWord> lastChildLeftRight = SemanticGraphUtils.leftRightMostChildVertices(insideNP.get(insideNP.size()-1), dep);
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); }
Pair<IndexedWord, IndexedWord> firstChildLeftRight = SemanticGraphUtils.leftRightMostChildVertices(insideNP.get(0), dep); Pair<IndexedWord, IndexedWord> lastChildLeftRight = SemanticGraphUtils.leftRightMostChildVertices(insideNP.get(insideNP.size()-1), dep);
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); }