我试过用 Hunspell 浏览 SourceForge 上的文档,但我仍然迷路了。是否有 C++ 初学者能够遵循的 hunspell 的体面示例?否则,是否有任何更易于使用的免费/开源拼写检查器?
最佳答案
我同意他们的网站有点难以浏览,而且没有很多教程。
我建议只潜入。
例如这里是 NHunspell
的一些代码,这只是 .net 版本。下面的代码只是基本用法,但对于入门的人来说仍然有用。
您可以从 Open Office
下载词典。 repository
//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
}
关于spell-checking - Hunspell 的示例/教程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17241531/