字典API(词法) [英] Dictionary API (lexical)

查看:171
本文介绍了字典API(词法)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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...

推荐答案

从像ASpell( http://aspell.net/)并将其加载到列表或您喜欢的任何结构中.

Grab the flat text file from an open source spellchecker like ASpell (http://aspell.net/) and load it into a List or whatever structure you like.

例如

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"); });

这篇关于字典API(词法)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆