public static Dictionary <string, int> GetWordFrequency(string path, PorterStemming porter) { Init(); var dic = new Dictionary <string, int>(); using (StreamReader reader = new StreamReader(path)) { string word = string.Empty; do { char c = (char)reader.Read(); if (Array.IndexOf(_delimiters, c) == -1 && !Char.IsWhiteSpace(c)) { word += c; continue; } word = word.ToLower(); if (_exceptionWords.Contains(word) || _stopWords.Contains(word) || word.Length < 3) { word = string.Empty; continue; } word = porter.Stem(word); if (dic.ContainsKey(word)) { dic[word] = dic[word] + 1; } else { dic[word] = 1; } word = string.Empty; } while (!reader.EndOfStream); } return(dic); }
public VectorialSearch() { Porter = new PorterStemming(); }