public Mispellings(IEnumerable <string> someWords, IEnumerable <string> correctWords) { trigramIndex = new TrigramIndex(correctWords); WordFrequencies = someWords .GroupBy(w => w, (w, ws) => Tuple.Create(w, ws.Count())) .ToDictionary(it => it.Item1, it => it.Item2); var unknownWords = WordFrequencies.Keys.Where(w => !trigramIndex.ContainsWord(w)); var levensteinInfos = RetrieveLevensteinInfos(unknownWords).ToList(); fuzzyDictionary = GetFuzzyDictionary(levensteinInfos); }
public string GetFixedOrNull(string word) { return(trigramIndex.ContainsWord(word) ? word : (fuzzyDictionary.ContainsKey(word) ? fuzzyDictionary[word] : null)); }