我试过用 Hunspell 浏览 SourceForge 上的文档,但我还是迷路了。是否有任何 C++ 初学者能够遵循的体面的 hunspell 示例?如果做不到这一点,是否有更容易使用的免费/开源拼写检查器?
问问题
2329 次
1 回答
4
我同意他们的网站有点难以浏览,并且没有太多的教程。
我建议只是潜水。
例如,这里有一些代码NHunspell
,它只是 .net 版本。下面的代码只是基本用法,但对于初学者来说仍然有用。
您可以从存储库下载字典Open Office
//affPath = path to the .aff file
//dictPath = path to the .dic file
// create and load your hunspell object
NHunspell.Hunspell hunspell = new NHunspell.Hunspell(affPath, dicPath);
// want to add a word that is not part of the base dictionary? Sure, we can do that.
hunspell.Add("stackoverflow");
//lets check if a word is valid
bool isValid = hunpsell.Spell("stackoverflowed");
if(!isValid)
{
//lets get some suggestions for this word
List<String> suggestions = hunspell.Suggest("stackoverflowed");
...do stuff with your list of suggestions
}
于 2013-11-15T21:54:30.417 回答