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); }
public void print() { String s = toString(); System.out.print(s); }
@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 static IntTuple getIntTuple(List<Integer> integers) { IntTuple t = IntTuple.getIntTuple(integers.size()); for (int i = 0; i < t.length(); i++) { t.set(i, integers.get(i).intValue()); } return t; }
allPredictedMentions.put(m.mentionID, m); IntTuple pos = new IntTuple(2); pos.set(0, i); pos.set(1, j); positions.put(m, pos); m.sentNum = i; m.corefClusterID = m.mentionID; IntTuple headPosition = new IntTuple(2); headPosition.set(0, i); headPosition.set(1, m.headIndex); mentionheadPositions.put(headPosition, m);
@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; }
posElems[i] = Integer.parseInt(bits[14 + i]); IntTuple position = new IntTuple(posElems); String span = unescapeSpace(bits[14 + posLen]); CorefChain.CorefMention mention = new CorefChain.CorefMention(
public IntTuple getCopy() { IntTuple copy = IntTuple.getIntTuple(elements.length); //new IntTuple(numElements); System.arraycopy(elements, 0, copy.elements, 0, elements.length); return copy; }
@Override public int hashCode() { return position.hashCode(); }
if (sentNum != that.sentNum) return false; if (!position.equals(that.position)) return false;
public static IntTuple getIntTuple(List<Integer> integers) { IntTuple t = IntTuple.getIntTuple(integers.size()); for (int i = 0; i < t.length(); i++) { t.set(i, integers.get(i).intValue()); } return t; }
/** 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)); } }
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); } }
public IntTuple getCopy() { IntTuple copy = IntTuple.getIntTuple(elements.length); //new IntTuple(numElements); System.arraycopy(elements, 0, copy.elements, 0, elements.length); return copy; }
@Override public int hashCode() { return position.hashCode(); }
if (sentNum != that.sentNum) return false; if (!position.equals(that.position)) return false;
/** 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); }