Example #1
0
 public CorefChain(CorefCluster c, Map<Mention, IntTuple> positions) {
   chainID = c.clusterID;
   // Collect mentions
   mentions = new ArrayList<>();
   mentionMap = Generics.newHashMap();
   CorefMention represents = null;
   for (Mention m : c.getCorefMentions()) {
     CorefMention men = new CorefMention(m, positions.get(m));
     mentions.add(men);
   }
   Collections.sort(mentions, new CorefMentionComparator());
   // Find representative mention
   for (CorefMention men : mentions) {
     IntPair position = new IntPair(men.sentNum, men.headIndex);
     if (!mentionMap.containsKey(position))
       mentionMap.put(position, Generics.<CorefMention>newHashSet());
     mentionMap.get(position).add(men);
     if (men.moreRepresentativeThan(represents)) {
       represents = men;
     }
   }
   representative = represents;
 }
Example #2
0
 @Override
 public boolean equals(Object aThat) {
   if (this == aThat) return true;
   if (!(aThat instanceof CorefChain)) return false;
   CorefChain that = (CorefChain) aThat;
   if (chainID != that.chainID) return false;
   if (!mentions.equals(that.mentions)) return false;
   if (representative == null && that.representative == null) {
     return true;
   }
   if (representative == null
       || that.representative == null
       || !representative.equals(that.representative)) {
     return false;
   }
   // mentionMap is another view of mentions, so no need to compare
   // that once we've compared mentions
   return true;
 }