static Boolean ItemExist(Dictionary <string, int> C, String newItem) { foreach (KeyValuePair <string, int> Tran in C) { int cpt = 0; foreach (String ItemC in Tran.Key.Split(',')) { foreach (String ne in newItem.Trim().Split(',')) { if (ItemC.Equals(ne)) { cpt++; continue; } } } if (cpt == Tran.Key.Split(',').Count()) { return(true); } } return(false); }
static Boolean ExistItemSet(String Item, String Set) { foreach (String ItemC in Set.Split(',')) { if (ItemC.Equals(Item)) { return(true); } } return(false); }
static Boolean ExistItem(String Item, String Transaction) { foreach (String ItemC in Transaction.Split(' ')) { if (ItemC.Equals(Item)) { return(true); } } return(false); }
static int getOCCItem(String Tran) { Dictionary <string, int> _TempCount = new Dictionary <string, int>(); foreach (String Line in Transactions) { string LineItem = Line.Trim(); if (LineItem.Split(' ').Count() < Tran.Split(',').Count()) { continue; } int cptLine = 0; //COMPARE BETWEEN COMIBINITION AND LINE TRANSACTION foreach (String ItemC in Tran.Split(',')) { foreach (String ItemL in Line.Trim().Split(' ')) { if (ItemC.Equals(ItemL)) { cptLine++; continue; } } } if (cptLine == Tran.Split(',').Count()) { if (_TempCount.ContainsKey(Tran)) { _TempCount[Tran] += 1; } else { _TempCount.Add(Tran, 1); } } } return(_TempCount[Tran]); }
static Dictionary <string, int> getCN(Dictionary <string, int> Ln_1, int N) { Dictionary <string, int> CN = new Dictionary <string, int>(); //CONCATENATION for (int i = 0; i < Ln_1.Count; i++) { for (int j = i + 1; j < Ln_1.Count; j++) { //ELIMINATE OCCURENCE IN EACH TRANSACTION String newItem = EliminateOcc(Ln_1.ElementAt(i).Key + "," + Ln_1.ElementAt(j).Key); if (newItem.Split(',').Count() != N) { continue; } // ELIMINATE OCCURENCE IN TRANSACTION if (!ItemExist(CN, newItem)) { //Console.WriteLine(newItem); CN.Add(newItem, 0); } } } Dictionary <string, int> _TempCount = new Dictionary <string, int>(); //GET SUPPORT COUNT foreach (KeyValuePair <String, int> Tran in CN) { foreach (String Line in Transactions) { string LineItem = Line.Trim(); if (LineItem.Split(' ').Count() < Tran.Key.Split(',').Count()) { continue; } int cptLine = 0; //COMPARE BETWEEN COMIBINITION AND LINE TRANSACTION foreach (String ItemC in Tran.Key.Split(',')) { foreach (String ItemL in Line.Trim().Split(' ')) { if (ItemC.Equals(ItemL)) { cptLine++; continue; } } } if (cptLine == Tran.Key.Split(',').Count()) { if (_TempCount.ContainsKey(Tran.Key)) { _TempCount[Tran.Key] += 1; } else { _TempCount.Add(Tran.Key, 1); } } } } foreach (KeyValuePair <String, int> Tran in _TempCount) { CN[Tran.Key] = Tran.Value; } return(CN); }