字典API(词汇)

fle*_*esh 18 .net c# api

有谁知道一个好的.NET字典API?我对意义不感兴趣,而是我需要能够以多种不同的方式查询单词 - 返回x长度的单词,返回部分匹配等等...

Jam*_*Orr 21

从像ASpell(http://aspell.net/)这样的开源拼写检查程序中获取平面文本文件,并将其加载到List或您喜欢的任何结构中.

例如,

List<string> words = System.IO.File.ReadAllText("MyWords.txt").Split(new string[]{Environment.NewLine}).ToList();

// C# 3.0 (LINQ) example:

    // get all words of length 5:
    from word in words where word.length==5 select word

    // get partial matches on "foo"
    from word in words where word.Contains("foo") select word

// C# 2.0 example:

    // get all words of length 5:
    words.FindAll(delegate(string s) { return s.Length == 5; });

    // get partial matches on "foo"
    words.FindAll(delegate(string s) { return s.Contains("foo"); });
Run Code Online (Sandbox Code Playgroud)

  • 为什么我只能投票一次?;) (2认同)