/// <summary> /// searches an index for the dictionary, and reports words which were found using a particular strategy. /// </summary> /// <param name="text">Word/phrase to match.</param> /// <param name="database">Dictionary database. You can obtain a list of available /// dictionary databases via <see cref="GetDatabases">GetDatabases</see>.</param> /// <param name="strategy">Search strategy to employ for matching. You can obtain a list of /// supported strategies via <see cref="GetMatchStrategies">GetMatchStrategies</see></param> /// <returns>A collection of matches as <see cref="WordMatchCollection" />.</returns> /// <remarks> /// <p>If the database name is specified with an exclamation point (decimal /// code 33, "!"), then all of the databases will be searched until a /// match is found, and all matches in that database will be displayed. </p> /// /// <p>If the database name is specified with a star (decimal code 42, "*"), /// then all of the matches in all available databases will be displayed.</p> /// /// <p>In both of these special cases, the databases will be searched in the same order /// as that printed by <see cref="GetDatabases">GetDatabases</see>.</p> /// </remarks> public WordMatchCollection GetMatches(string text, string database, string strategy) { if (database == null || database.Length == 0) { database = "*"; } string command = string.Concat("MATCH ", database, " ", strategy, " ", text); string[] responses = ExecuteCommand(command).Split('\n'); WordMatchCollection wordMatches = new WordMatchCollection(); for (int i = 0; i < responses.Length; i++) { if (responses[i].Length == 0) { continue; } Match m = reDatabaseAndWordMatch.Match(responses[i]); string db = m.Groups[1].Value; string wordMatch = m.Groups[2].Value; wordMatches.Add(new WordMatch(wordMatch, db)); } return(wordMatches); }
/// <summary> /// searches an index for the dictionary, and reports words which were found using a particular strategy. /// </summary> /// <param name="text">Word/phrase to match.</param> /// <param name="database">Dictionary database. You can obtain a list of available /// dictionary databases via <see cref="GetDatabases">GetDatabases</see>.</param> /// <param name="strategy">Search strategy to employ for matching. You can obtain a list of /// supported strategies via <see cref="GetMatchStrategies">GetMatchStrategies</see></param> /// <returns>A collection of matches as <see cref="WordMatchCollection" />.</returns> /// <remarks> /// <p>If the database name is specified with an exclamation point (decimal /// code 33, "!"), then all of the databases will be searched until a /// match is found, and all matches in that database will be displayed. </p> /// /// <p>If the database name is specified with a star (decimal code 42, "*"), /// then all of the matches in all available databases will be displayed.</p> /// /// <p>In both of these special cases, the databases will be searched in the same order /// as that printed by <see cref="GetDatabases">GetDatabases</see>.</p> /// </remarks> public WordMatchCollection GetMatches(string text, string database, string strategy) { if (database == null || database.Length == 0) database = "*"; string command = string.Concat ("MATCH ", database, " ", strategy, " ", text); string[] responses = ExecuteCommand (command).Split ('\n'); WordMatchCollection wordMatches = new WordMatchCollection(); for (int i=0; i<responses.Length; i++) { if (responses[i].Length == 0) continue; Match m = reDatabaseAndWordMatch.Match (responses[i]); string db = m.Groups[1].Value; string wordMatch = m.Groups[2].Value; wordMatches.Add (new WordMatch(wordMatch, db)); } return wordMatches; }