@Override public boolean equals(Object iO) { if (!(iO instanceof IntTuple)) { return false; } IntTuple i = (IntTuple) iO; if (i.elements.length != elements.length) { return false; } for (int j = 0; j < elements.length; j++) { if (elements[j] != i.get(j)) { return false; } } return true; }
/** Print coref link info */ private static void printLink(Logger logger, String header, IntTuple src, IntTuple dst, List<List<Mention>> orderedMentionsBySentence) { Mention srcMention = orderedMentionsBySentence.get(src.get(0)).get(src.get(1)); Mention dstMention = orderedMentionsBySentence.get(dst.get(0)).get(dst.get(1)); if(src.get(0)==dst.get(0)) { logger.fine(header + ": ["+srcMention.spanToString()+"](id="+srcMention.mentionID +") in sent #"+src.get(0)+" => ["+dstMention.spanToString()+"](id="+dstMention.mentionID+") in sent #"+dst.get(0) + " Same Sentence"); } else { logger.fine(header + ": ["+srcMention.spanToString()+"](id="+srcMention.mentionID +") in sent #"+src.get(0)+" => ["+dstMention.spanToString()+"](id="+dstMention.mentionID+") in sent #"+dst.get(0)); } }
@Override public String toString() { StringBuilder name = new StringBuilder(); for (int i = 0; i < elements.length; i++) { name.append(get(i)); if (i < elements.length - 1) { name.append(' '); } } return name.toString(); }
int classOf(int index) { IntTuple i = featureIndex.get(index); return i.get(0); }
for (int i = p2.get(0) ; i<= p1.get(0) ; i++){ if(p1.get(0)==p2.get(0)) { menDist = p1.get(1)-p2.get(1); break; if(i==p2.get(0)) { menDist += orderedMentionsBySentence.get(p2.get(0)).size()-p2.get(1); continue; if(i==p1.get(0)) { menDist += p1.get(1); continue; if(p2.get(0)<i && i < p1.get(0)) menDist += orderedMentionsBySentence.get(i).size(); logger.finest("\nsentence distance: "+(p1.get(0)-p2.get(0))+"\tmention distance: "+menDist + correct);
/** * the feature number of the original feature or -1 if this is for a prior * */ int featureOf(int index) { IntTuple i = featureIndex.get(index); if (i.length() == 1) { return -1; } return i.get(1); }
while (dst.get(0) > src.get(0) || (dst.get(0) == src.get(0) && dst.get(1) > src.get(1))) { Mention dstMention = goldMentions.get(dst.get(0)).get(dst.get(1)); m.originalRef = dstMention.originalRef; dstMention.originalRef = id; for (int k = dst.get(0); k <= src.get(0); k++) { for (int l = 0; l < goldMentions.get(k).size(); l++) { 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);
while (dst.get(0) > src.get(0) || (dst.get(0) == src.get(0) && dst.get(1) > src.get(1))) { Mention dstMention = goldOrderedMentionsBySentence.get(dst.get(0)).get(dst.get(1)); m.originalRef = dstMention.originalRef; dstMention.originalRef = id; for (int k = dst.get(0); k <= src.get(0); k++) { for (int l = 0; l < goldOrderedMentionsBySentence.get(k).size(); l++) { 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);
@Override public int compareTo(IntTuple o) { int commonLen = Math.min(o.length(), length()); for (int i = 0; i < commonLen; i++) { int a = get(i); int b = o.get(i); if (a < b) return -1; if (b < a) return 1; } if (o.length() == length()) { return 0; } else { return (length() < o.length())? -1: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); }
pw.print(" " + mention.position.length()); for(int i = 0; i < mention.position.length(); i ++) pw.print(" " + mention.position.get(i)); pw.print(" " + escapeSpace(mention.mentionSpan)); pw.println();
/** 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); }
int srcSent = link.first.get(0); int srcTok = corefDoc.getOrderedMentions().get(srcSent - 1).get(link.first.get(1)-1).headIndex + 1; int dstSent = link.second.get(0); int dstTok = corefDoc.getOrderedMentions().get(dstSent - 1).get(link.second.get(1)-1).headIndex + 1; IntTuple dst = new IntTuple(2); dst.set(0, dstSent);
List<List<Mention>> goldOrderedMentionsBySentence = document.goldOrderedMentionsBySentence; Mention srcMention = orderedMentionsBySentence.get(src.get(0)).get(src.get(1)); Mention dstMention = orderedMentionsBySentence.get(dst.get(0)).get(dst.get(1)); List<CoreLabel> srcSentence = srcMention.sentenceWords; List<CoreLabel> dstSentence = dstMention.sentenceWords; Counter<Integer> mEnd = new ClassicCounter<>(); for(Mention m : goldOrderedMentionsBySentence.get(src.get(0))){ mBegin.incrementCount(m.startIndex); mEnd.incrementCount(m.endIndex); List<CoreLabel> l = document.annotation.get(CoreAnnotations.SentencesAnnotation.class).get(src.get(0)).get(CoreAnnotations.TokensAnnotation.class); for(int i = 0 ; i < l.size() ; i++){ for(int j = 0; j < mEnd.getCount(i); j++){ mEnd = new ClassicCounter<>(); for(Mention m : goldOrderedMentionsBySentence.get(dst.get(0))){ mBegin.incrementCount(m.startIndex); mEnd.incrementCount(m.endIndex); l = document.annotation.get(CoreAnnotations.SentencesAnnotation.class).get(dst.get(0)).get(CoreAnnotations.TokensAnnotation.class); for(int i = 0 ; i < l.size() ; i++){ for(int j = 0; j < mEnd.getCount(i); j++){
.setHeadIndex(mention.headIndex - 1) .setSentenceIndex(mention.sentNum - 1) .setPosition(mention.position.get(1)) );