/// <summary> /// For each ws in ms, add to the set of strings under that key in results the words from that alternative. /// If the alternative contains more than maxWords words, skip it. /// </summary> /// <param name="ms"></param> /// <param name="results"></param> /// <param name="maxWords"></param> private void AddKeysFrom(IMultiAccessorBase ms, Dictionary <int, HashSet <string> > results, int maxWords) { foreach (var ws in ms.AvailableWritingSystemIds) { string wordSource = ms.get_String(ws).Text; if (wordSource == null) { continue; } var words = (from Match match in WordParsingRegex.Matches(wordSource) select match.Value).ToArray(); if (words.Length > maxWords) { continue; } HashSet <string> wordSet; if (!results.TryGetValue(ws, out wordSet)) { wordSet = new HashSet <string>(); results[ws] = wordSet; } foreach (var word in words) { wordSet.Add(word); } } }
private IEnumerable <string> ParseStringIntoWords(string searchIn) { return((from Match match in WordParsingRegex.Matches(searchIn) select match.Value).ToArray()); }