private void populateSeqPairs(ItemPairsCount seqPairs, string[] seq)
 {
     for (int i = 0; i < seq.Count() - 1; i++)
     {
         ItemPair pair = new ItemPair(seq[i], seq[i + 1]);
         seqPairs.addPair(pair);
     }
 }
 private void populateAllPairs(ItemPairsCount allPairs, string[] seq)
 {
     string[] distinctSeq = seq.Distinct().ToArray();
     for (int i = 0; i < distinctSeq.Count() - 1; i++)
     {
         for (int j = i + 1; j < distinctSeq.Count(); j++)
         {
             ItemPair pair = seq[i].CompareTo(seq[j]) < 0 ? new ItemPair(seq[i], seq[j]) : new ItemPair(seq[j], seq[i]);
             allPairs.addPair(pair);
         }
     }
 }
        public void TrainCpModel()
        {
            ItemPairsCount allPairs  = new ItemPairsCount();
            ItemsCounts    allCounts = new ItemsCounts();

            if (trainSet == null)
            {
                throw new NullReferenceException("train set must be initialize first");
            }

            foreach (var session in trainSet)
            {
                populateAllPairs(allPairs, session);
                populateAllCounts(allCounts, session);
            }

            items.addAllPairs(allPairs);
            items.addAllCount(allCounts);
        }