private void AddWordToClass(string word, BayesClass classInstance) { if (classInstance.UniqueWords.ContainsKey(word)) { classInstance.UniqueWords[word]++; } else { classInstance.UniqueWords.Add(word, 1); } }
public void AddDocumentToClass(string document, string className) { var classInstance = bayesClassList.FirstOrDefault(x => x.Name == className); if (className == null) { classInstance = new BayesClass(); bayesClassList.Add(classInstance); } var words = document.Split(' ').Where(x => x.Length > MinimalWordsLength); foreach (var word in words) { AddWordToClass(word, classInstance); } classInstance.DocumentsCount++; }