IntTuple headPosition = new IntTuple(2); headPosition.set(0, paragraph.size()-1 + paragraphOffset); headPosition.set(1, i);
IntTuple headPosition = new IntTuple(2); headPosition.set(0, paragraph.size()-1 + paragraphOffset); headPosition.set(1, i);
posElems[i] = Integer.parseInt(bits[14 + i]); IntTuple position = new IntTuple(posElems); String span = unescapeSpace(bits[14 + posLen]); CorefChain.CorefMention mention = new CorefChain.CorefMention(
IntTuple src = new IntTuple(2); src.set(0,i); src.set(1,j);
private String findNextParagraphSpeaker(List<CoreMap> paragraph, int paragraphOffset, Dictionaries dict) { CoreMap lastSent = paragraph.get(paragraph.size()-1); String speaker = ""; for(CoreLabel w : lastSent.get(CoreAnnotations.TokensAnnotation.class)) { if(w.get(CoreAnnotations.LemmaAnnotation.class).equals("report") || w.get(CoreAnnotations.LemmaAnnotation.class).equals("say")) { String word = w.get(CoreAnnotations.TextAnnotation.class); SemanticGraph dependency = lastSent.get(SemanticGraphCoreAnnotations.EnhancedDependenciesAnnotation.class); IndexedWord t = dependency.getNodeByWordPattern(word); for(Pair<GrammaticalRelation,IndexedWord> child : dependency.childPairs(t)){ if(child.first().getShortName().equals("nsubj")) { int subjectIndex = child.second().index(); // start from 1 IntTuple headPosition = new IntTuple(2); headPosition.set(0, paragraph.size()-1 + paragraphOffset); headPosition.set(1, subjectIndex-1); if(mentionheadPositions.containsKey(headPosition) && mentionheadPositions.get(headPosition).nerString.startsWith("PER")) { speaker = Integer.toString(mentionheadPositions.get(headPosition).mentionID); } } } } } return speaker; }
private static boolean findSubject(Document doc, SemanticGraph dependency, IndexedWord w, int sentNum, int utterNum) { for(Pair<GrammaticalRelation,IndexedWord> child : dependency.childPairs(w)){ if(child.first().getShortName().equals("nsubj")) { String subjectString = child.second().word(); int subjectIndex = child.second().index(); // start from 1 IntTuple headPosition = new IntTuple(2); headPosition.set(0, sentNum); headPosition.set(1, subjectIndex-1); String speaker; if(doc.mentionheadPositions.containsKey(headPosition)) { speaker = Integer.toString(doc.mentionheadPositions.get(headPosition).mentionID); } else { speaker = subjectString; } doc.speakers.put(utterNum, speaker); return true; } } return false; }
private static String findNextParagraphSpeaker(Document doc, List<CoreMap> paragraph, int paragraphOffset, Dictionaries dict) { if (paragraph.isEmpty()) { return ""; } CoreMap lastSent = paragraph.get(paragraph.size()-1); String speaker = ""; for(CoreLabel w : lastSent.get(CoreAnnotations.TokensAnnotation.class)) { if(w.get(CoreAnnotations.LemmaAnnotation.class).equals("report") || w.get(CoreAnnotations.LemmaAnnotation.class).equals("say")) { String word = w.get(CoreAnnotations.TextAnnotation.class); SemanticGraph dependency = lastSent.get(SemanticGraphCoreAnnotations.EnhancedDependenciesAnnotation.class); if (dependency == null) { dependency = lastSent.get(SemanticGraphCoreAnnotations.BasicDependenciesAnnotation.class); } IndexedWord t = dependency.getNodeByWordPattern(word); for(Pair<GrammaticalRelation,IndexedWord> child : dependency.childPairs(t)){ if(child.first().getShortName().equals("nsubj")) { int subjectIndex = child.second().index(); // start from 1 IntTuple headPosition = new IntTuple(2); headPosition.set(0, paragraph.size()-1 + paragraphOffset); headPosition.set(1, subjectIndex-1); if(doc.mentionheadPositions.containsKey(headPosition) && doc.mentionheadPositions.get(headPosition).nerString.startsWith("PER")) { speaker = Integer.toString(doc.mentionheadPositions.get(headPosition).mentionID); } } } } } return speaker; }
public static IntTuple getIntTuple(int num) { if (num == 1) { return new IntUni(); } if ((num == 2)) { return new IntPair(); } if (num == 3) { return new IntTriple(); } if (num == 4) { return new IntQuadruple(); } else { return new IntTuple(num); } }
Mention m = goldOrderedMentionsBySentence.get(i).get(j); int id = m.mentionID; IntTuple pos = new IntTuple(2); pos.set(0, i); pos.set(1, j); if (k == dst.get(0) && l < dst.get(1)) continue; if (k == src.get(0) && l > src.get(1)) break; IntTuple missed = new IntTuple(2); missed.set(0, k); missed.set(1, l);
String subjectString = child.second().word(); int subjectIndex = child.second().index(); // start from 1 IntTuple headPosition = new IntTuple(2); headPosition.set(0, sentNum); headPosition.set(1, subjectIndex-1);
public CorefMention(Mention m, IntTuple pos){ mentionType = m.mentionType; number = m.number; gender = m.gender; animacy = m.animacy; startIndex = m.startIndex + 1; endIndex = m.endIndex + 1; headIndex = m.headIndex + 1; corefClusterID = m.corefClusterID; sentNum = m.sentNum + 1; mentionID = m.mentionID; mentionSpan = m.spanToString(); // index starts from 1 position = new IntTuple(2); position.set(0, pos.get(0)+1); position.set(1, pos.get(1)+1); m.headWord.set(CorefCoreAnnotations.CorefClusterIdAnnotation.class, corefClusterID); }
/** This constructor builds the external CorefMention class from the internal Mention. */ public CorefMention(Mention m, IntTuple pos){ mentionType = m.mentionType; number = m.number; gender = m.gender; animacy = m.animacy; startIndex = m.startIndex + 1; endIndex = m.endIndex + 1; headIndex = m.headIndex + 1; corefClusterID = m.corefClusterID; sentNum = m.sentNum + 1; mentionID = m.mentionID; mentionSpan = m.spanToString(); // index starts from 1 position = new IntTuple(2); position.set(0, pos.get(0)+1); position.set(1, pos.get(1)+1); m.headWord.set(CorefCoreAnnotations.CorefClusterIdAnnotation.class, corefClusterID); }
mentionProto.getMentionID(), mentionProto.getSentenceIndex() + 1, new IntTuple(new int[]{ mentionProto.getSentenceIndex() + 1, mentionProto.getPosition() }), mentionSpan.substring(mentionSpan.length() > 0 ? 1 : 0));
mentionProto.getMentionID(), mentionProto.getSentenceIndex() + 1, new IntTuple(new int[]{ mentionProto.getSentenceIndex() + 1, mentionProto.getPosition() }), mentionSpan.substring(mentionSpan.length() > 0 ? 1 : 0));