在MacOS上,hunspell在Library / Spelling /中找不到现有的.aff和.dic文件

时间:2019-06-03 14:48:05

标签: macos emacs hunspell spelling

我已经通过brew命令下载了hunspell,并希望在Emacs中使用它,但是hunspell似乎没有在〜/ Library / Spelling中找到我的.aff和.dic文件,即使它们存在。 >

使用命令行命令“ hunspell -D”,结果为:

搜索路径: 。:: / usr / share / hunspell:/ usr / share / myspell:/ usr / share / myspell / dicts:/ Library / Spelling:/Users/macbook/.openoffice.org/3/user/wordbook:/ Users / macbook / .openoffice.org2 / user / wordbook:/Users/macbook/.openoffice.org2.0/user/wordbook:/ Users / macbook / 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选项,路径不是必需的): / Users / macbook / Library / Spelling / cs_CZ

在这里,cs_CZ是存储我的个人拼写的文件的名称。文件夹中还有其他文件,包括cs_CZ.aff和cs_CZ.dic以及en_GB,但是hunspell只会忽略这些文件。

在Emacs中,我尝试过:

(setenv "DICPATH"
    (concat (getenv "HOME") "/Library/Spelling"))
(when (executable-find "hunspell")
      (setq-default ispell-program-name "hunspell")
      (setq ispell-really-hunspell t))

在使用建议输入“ czech”运行ispell-change-dictinary之后,ispell-word会给我:

使用捷克语词典开始新的Ispell过程hunspell ... ispell-init-process:无法打开名为“ czech”的字典的词缀或字典文件。

...和flyspell-mode:

启用Flyspell模式时出错: (无法打开名为“ czech”的字典的词缀或字典文件。)

谢谢。

1 个答案:

答案 0 :(得分:0)

Emacs中的拼写检查器在两个字典中查找拼写:标准字典和个人字典。标准字典由变量aaa 指定,如果由ispell-local-dictionary指定,则由变量nil指定。正如我在您的输出中看到的那样,Hunspell只有ispell-dictionary,而没有cs_CZ字典:

czech

顺便说一句,Hunspell 1.7.0被打破了。有关更多信息,请参见:https://github.com/hunspell/hunspell/issues/608。您可以比较两者之间的输出

AVAILABLE DICTIONARIES (path is not mandatory for -d option):
/Users/macbook/Library/Spelling/cs_CZ

hunspell -D

看看有什么区别。

首先,设置所需的已安装词典名称:

hunspell -D /dev/null

要查看已找到并已解析的词典的列表,请使用 C-h v ;; Default dictionary to use (setq ispell-local-dictionary "czech")

此外,我建议您将您喜欢的词典添加到ispell-hunspell-dict-paths-alist中。此变量用于指定词典及其相关参数的 alist 。请注意,您必须在ispell-local-dictionary-alist中使用相同的词典名称a。这样的事情应该起作用:

ispell-dictionary

请注意,Homebrew本身不提供Hunspell的词典,但是您可以下载 其他来源的兼容字典,例如https://extensions.libreoffice.org/en/extensions/show/czech-dictionaries。有关说明,请参见:https://passingcuriosity.com/2017/emacs-hunspell-and-dictionaries

最后,我强烈建议在macOS上设置;; Here ("-d" "cs_CZ") id dictionary file name. ;; You could use '("-d" "file1,file2")' to check with multiple dictionaries. (add-to-list 'ispell-local-dictionary-alist '(("czech" "[[:alpha:]]" "[^[:alpha]]" "[0-9']" t ("-d" "cs_CZ") nil utf-8))) 环境变量。没有此变量,您将在macOS上看到以下内容:

无法打开名为“ XXX”的字典的词缀或字典文件

我设法在macOS上重现此问题。但是在Linux上,使用相同的配置和Emacs版本,一切正常。要设置字典文件名,请使用DICTIONARY defun,如下所示:

setenv

此环境变量由Hunspell使用。有关更多信息,请参见(when (string-equal system-type "darwin") ; There is no problem on Linux ;; Dictionary file name (setenv "DICTIONARY" "cs_CZ"))

相关问题