如何在 Windows 上的 hunspell 搜索路径中添加字典路径?

Posted

技术标签:

【中文标题】如何在 Windows 上的 hunspell 搜索路径中添加字典路径?【英文标题】:How to add dictionary path in search path for hunspell on windows? 【发布时间】:2020-06-19 05:48:11 【问题描述】:

以下链接说明了在windows上安装hunspell的cygwin方法:https://github.com/hunspell/hunspell

已安装的可执行文件具有类似unix的字典搜索路径,如下所示:

$ hunspell.exe -D

搜索路径: .::/usr/share/hunspell:/usr/share/myspell:/usr/share/myspell/dicts:/Library/Spelling:/home/nchaturv/.openoffice.org/3/user/wordbook:/home/ nchaturv/.openoffice.org2/user/wordbook:/home/nchaturv/.openoffice.org2.0/user/wordbook:/home/nchaturv/Library/Spelling:/opt/openoffice.org/basis3.0/share/dict /ooo:/usr/lib/openoffice.org/basis3.0/share/dict/ooo:/opt/openoffice.org2.4/share/dict/ooo:/usr/lib/openoffice.org2.4/share/ dict/ooo:/opt/openoffice.org2.3/share/dict/ooo:/usr/lib/openoffice.org2.3/share/dict/ooo:/opt/openoffice.org2.2/share/dict/ooo :/usr/lib/openoffice.org2.2/share/dict/ooo:/opt/openoffice.org2.1/share/dict/ooo:/usr/lib/openoffice.org2.1/share/dict/ooo: /opt/openoffice.org2.0/share/dict/ooo:/usr/lib/openoffice.org2.0/share/dict/ooo

可用字典(-d 选项的路径不是必需的):

上面的路径是 unix 路径而不是 windows 路径。并且没有默认字典所以,我必须将字典 en_US.dic 添加到搜索路径中。

有没有办法在配置或构建时向搜索库路径添加一些路径?我尝试使用以下方法,但没有成功。

export LDFLAGS='-L/home/foo/sw/lib/'

如果我运行 hunspell 的文件夹中有 en_US.dic 文件,我不会收到字典不存在错误。但是,我想在搜索路径中添加一个路径,并将字典和词缀文件放在那里。

【问题讨论】:

LDFLAGS 仅用于编译程序。 cygwin Hunspell 程序在/usr/share/myspell下有字典 【参考方案1】:

解读https://github.com/hunspell/hunspell/blob/master/src/tools/hunspell.cxx#L2040-L2072处的源码,可以使用DICPATH在运行时添加目录。一些目录派生自HOME,但带有硬编码后缀。除了修补源代码之外,似乎没有任何方法可以在配置或构建时更改任何其他目录。

【讨论】:

以上是关于如何在 Windows 上的 hunspell 搜索路径中添加字典路径?的主要内容,如果未能解决你的问题,请参考以下文章

使用 Visual Studio 编译 hunspell

javascript 使用基于hunspell的“node-spellchecked”检查翻译文件的拼写问题

Windows 7 上的 Tiny C 编译器 [重复]

Windows域环境“3难”?弋搜日志系统教你如何轻松解决!

通过 NHunspell 在 Windows Phone 8.1 应用程序中缺少 kernel32.dll

打开 Office 拼写检查器/Java API