public CorefChain(CorefCluster c, IDictionary <Mention, IntTuple> positions)
 {
     chainID = c.clusterID;
     // Collect mentions
     mentions   = new List <CorefChain.CorefMention>();
     mentionMap = Generics.NewHashMap();
     CorefChain.CorefMention represents = null;
     foreach (Mention m in c.GetCorefMentions())
     {
         CorefChain.CorefMention men = new CorefChain.CorefMention(m, positions[m]);
         mentions.Add(men);
     }
     mentions.Sort(new CorefChain.CorefMentionComparator());
     // Find representative mention
     foreach (CorefChain.CorefMention men_1 in mentions)
     {
         IntPair position = new IntPair(men_1.sentNum, men_1.headIndex);
         if (!mentionMap.Contains(position))
         {
             mentionMap[position] = Generics.NewHashSet <CorefChain.CorefMention>();
         }
         mentionMap[position].Add(men_1);
         if (men_1.MoreRepresentativeThan(represents))
         {
             represents = men_1;
         }
     }
     representative = represents;
 }
        // Update incompatibles for two clusters that are about to be merged
        public virtual void MergeIncompatibles(CorefCluster to, CorefCluster from)
        {
            IList <Pair <Pair <int, int>, Pair <int, int> > > replacements = new List <Pair <Pair <int, int>, Pair <int, int> > >();

            foreach (Pair <int, int> p in incompatibleClusters)
            {
                int other = null;
                if (p.first == from.clusterID)
                {
                    other = p.second;
                }
                else
                {
                    if (p.second == from.clusterID)
                    {
                        other = p.first;
                    }
                }
                if (other != null && other != to.clusterID)
                {
                    int cid1 = Math.Min(other, to.clusterID);
                    int cid2 = Math.Max(other, to.clusterID);
                    replacements.Add(Pair.MakePair(p, Pair.MakePair(cid1, cid2)));
                }
            }
            foreach (Pair <Pair <int, int>, Pair <int, int> > r in replacements)
            {
                incompatibleClusters.Remove(r.first);
                incompatibleClusters.Add(r.second);
            }
        }
        public virtual void MergeAcronymCache(CorefCluster to, CorefCluster from)
        {
            IDictionary <Pair <int, int>, bool> replacements = Generics.NewHashMap();

            foreach (Pair <int, int> p in acronymCache.Keys)
            {
                if (acronymCache[p])
                {
                    int other = null;
                    if (p.first == from.clusterID)
                    {
                        other = p.second;
                    }
                    else
                    {
                        if (p.second == from.clusterID)
                        {
                            other = p.first;
                        }
                    }
                    if (other != null && other != to.clusterID)
                    {
                        int cid1 = Math.Min(other, to.clusterID);
                        int cid2 = Math.Max(other, to.clusterID);
                        replacements[Pair.MakePair(cid1, cid2)] = true;
                    }
                }
            }
            foreach (Pair <int, int> p_1 in replacements.Keys)
            {
                acronymCache[p_1] = replacements[p_1];
            }
        }
        // null if it's not conll input
        public virtual bool IsIncompatible(CorefCluster c1, CorefCluster c2)
        {
            // Was any of the pairs of mentions marked as incompatible
            int cid1 = Math.Min(c1.clusterID, c2.clusterID);
            int cid2 = Math.Max(c1.clusterID, c2.clusterID);

            return(incompatibleClusters.Contains(Pair.MakePair(cid1, cid2)));
        }