💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
# Hunspell Token Filter(Hunspell 词元过滤器) ## 简述 Hunspell过滤器是Hunspell的基础。Hunspell字典将从文件系统上的专用hunspell目录( `<path.conf>/hunspell` )中`<path.conf>/hunspell` 。 预期每个字典都有自己的目录,以其关联的语言环境(语言)命名。 这个字典目录预计会保存一个`*.aff`和一个或多个`*.dic`文件(所有这些文件将自动被读取)。 例如,假设使用默认的hunspell位置,以下目录布局将定义`en_US`字典: | `- conf` `|-- hunspell` `|    |-- en_US` `|    |    |-- en_US.dic` `|    |    |-- en_US.aff` | ## 参数 每个字典都可以进行一个设置: ignore_case 如果为true,字典匹配将不区分大小写(默认为false ) 这个设置可以在`elasticsearch.yml`使用全局`elasticsearch.yml` * `indices.analysis.hunspell.dictionary.ignore_case` 或指定特定字典: * `indices.analysis.hunspell.dictionary.en_US.ignore_case` 。 还可以在保存这些设置的`settings.yml`目录下添加`settings.yml`文件(这将覆盖在`elasticsearch.yml`定义的任何其他设置)。 可以通过配置分析设置来使用hunspell过滤器: | `{` `"analysis"` `: {` `"analyzer"` `: {` `"en"` `: {` `"tokenizer"` `: ``"standard"``,` `"filter"` `: [ ``"lowercase"``, ``"en_US"` `]` `}` `},` `"filter"` `: {` `"en_US"` `: {` `"type"` `: ``"hunspell"``,` `"locale"` `: ``"en_US"``,` `"dedup"` `: ``true` `}` `}` `}` `}` | hunspell过滤器接受四个选项: locale 此过滤器的区域设置。 如果这没有设置,则使用lang或者language来代替它们,因此必须设置其中一个。 dictionary 字典的名称 您的hunspell字典的路径应通过indices.analysis.hunspell.dictionary.location 。 dedup 如果需要返回单条结果,则需要将其设置为true 。 默认为true 。 longest_only 如果只返回最长的结果,请将其设置为true 。 默认为false :返回所有可能的结果。 与(基于算法的) snowball stemmers(雪球词干分析器)相反,这是基于词典查找的,因此词干的质量由词典的质量决定。 ## 加载字典 默认情况下,当节点启动时,将为该字典检查默认的Hunspell目录( `config/hunspell/` ),并自动加载任何字典。 通过在配置文件`indices.analysis.hunspell.dictionary.lazy`设置为`true` ,可以将字典加载实际使用。   ## 参考 Hunspell是一个拼写检查器和形态分析器,专为具有丰富形态和复杂的字复合和字符编码的语言而设计。 1. 维基百科, [http://en.wikipedia.org/wiki/Hunspell](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=http://en.wikipedia.org/wiki/Hunspell&usg=ALkJrhhTe4SNBi-yzE2Ium7lZbYNdA0rjA) 2. 源代码, [http://hunspell.sourceforge.net/](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=http://hunspell.sourceforge.net/&usg=ALkJrhjW2G8qRbu0lZQh2LVWUBJYgNKtWQ) 3. 开放办公室Hunspell字典, [http://wiki.openoffice.org/wiki/Dictionaries](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=http://wiki.openoffice.org/wiki/Dictionaries&usg=ALkJrhjol_nl3ZVfCZVXqDENOiy7iD3A8g) 4. Mozilla Hunspell字典, [https://addons.mozilla.org/en-US/firefox/language-tools/](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=https://addons.mozilla.org/en-US/firefox/language-tools/&usg=ALkJrhjkouoWClkhvx3I7BTP9HzM9bIOtw) 5. Chromium Hunspell字典, [http://src.chromium.org/viewvc/chrome/trunk/deps/third_party/hunspell_dictionaries/](https://translate.googleusercontent.com/translate_c?depth=1&hl=zh-CN&rurl=translate.google.com&sl=en&sp=nmt4&tl=zh-CN&u=http://src.chromium.org/viewvc/chrome/trunk/deps/third_party/hunspell_dictionaries/&usg=ALkJrhjpxkhrlh-puMLQPulnPxd5rDvdxw)