public static Dictionary <string, documentFreq> updateDictionary(Dictionary <string, documentFreq> doc1Dict, string cleanLine2) { Dictionary <string, documentFreq> doc2Dict = doc1Dict; documentFreq doc2FreqObj = new documentFreq(); string[] words = cleanLine2.Split(','); foreach (string input in words) { string word = input; if (!doc2Dict.ContainsKey(word)) { doc2FreqObj.doc1Freq = 0; doc2FreqObj.doc2Freq = 1; doc2Dict.Add(word, doc2FreqObj); } else if (doc2Dict.ContainsKey(word)) { doc2FreqObj.doc1Freq = doc2Dict[word].doc1Freq; doc2FreqObj.doc2Freq++; doc2Dict[word] = doc2FreqObj; } } return(doc2Dict); }
public static Dictionary <string, documentFreq> createDictionary(string cleanLine) { Dictionary <string, documentFreq> doc1Dict = new Dictionary <string, documentFreq>(); documentFreq docsFreqObj = new documentFreq(); string[] words = cleanLine.Split(','); foreach (string input in words) { string word = input; if (!doc1Dict.ContainsKey(word)) { docsFreqObj.doc1Freq = 1; doc1Dict.Add(word, docsFreqObj); } else if (doc1Dict.ContainsKey(word)) { int newFreq = docsFreqObj.doc1Freq++; doc1Dict[word].doc1Freq = newFreq; } } return(doc1Dict); }