Alex Rivera | Logout

Dictionary API (lexical)

Asked 2008-12-02T21:27:30.577
18

Does anyone know a good .NET dictionary API? I'm not interested in meanings, rather I need to be able to query words in a number of different ways - return words of x length, return partial matches and so on...

Edit
Report

1 Answer

2

I'm with Barry Fandango on this one, but you can do it without LINQ. .NET 2.0 has some nice filtering methods on the List(T) type. The one I suggest is

List(T).FindAll(Predicate(T)) : List(T)

This method will put every element in the list through the predicate method and return the list of words that return 'true'. So, load your words as suggested from an open source dictionary into a List(String). To find all words of length 5...

List(String) words = LoadFromDictionary();
List(String) fiveLetterWords = words.FindAll(delegate(String word)
    {
        return word.Length == 5;
    });

Or for all words starting with 'abc'...

List(String) words = LoadFromDictionary();
List(String) abcWords = words.FindAll(delegate(String word)
    {
        return word.StartsWith('abc');
    });
answered 2008-12-03T14:20:30.440

Your Answer