elasticsearch - 使用 elasticsearch 的真实单词拼写检查器

标签 elasticsearch spell-checking

我已经熟悉 Elasticsearch 的拼写检查器,我可以使用 suggest API 构建一个简单的拼写检查器。问题是,有一种拼写错误的单词,称为“真实单词”拼写错误。真实单词拼写错误发生在书写单词拼写错误时,创建了索引数据中存在的另一个单词,因此词汇拼写检查器无法纠正它,因为单词在词汇上是正确的。

例如,考虑查询“How to bell my laptop?”。“bell”的用户意思是“销售”,但“bell”出现在索引词汇中。因此,拼写检查程序让它成为现实。

查找和纠正真实单词拼写错误的想法是使用索引数据 n-gram 的频率。如果当前 n-gram 的频率非常低,而另一方面在索引数据中有一个非常相似的高频 n-gram,那么我们很可能有一个真实的单词拼写错误。

我想知道是否有一种方法可以使用 elasticsearch API 实现这种拼写检查?

最佳答案

在我搜索了一段时间之后,我发现使用 phrase_suggester 可以实现这样的事情。

    POST v2_201911/_search
{
  "suggest": {
    "text": "how to bell my laptop",
    "simple_phrase": {
      "phrase": {
        "field": "content",
        "gram_size": 2,
        "real_word_error_likelihood": 0.95,
        "direct_generator": [
          {
            "field": "content",
            "suggest_mode": "always",
            "prefix_length": 0,
            "min_word_length": 1
          }
        ],
        "highlight": {
          "pre_tag": "<em>",
          "post_tag": "</em>"
        }
      }
    }
  }
}

根据 documentation :

real_word_error_likelihood :

The likelihood of a term being a misspelled even if the term exists in the dictionary. The default is 0.95, meaning 5% of the real words are misspelled.

关于elasticsearch - 使用 elasticsearch 的真实单词拼写检查器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62261684/

相关文章:

java - 向 Eclipse 添加字典以进行除英文以外的拼写检查

elasticsearch - 如何在基于字段的 Elasticsearch 中获取唯一文档,以及如何基于其他字段 'group by'结果

elasticsearch - Elastic Search如何选择列并通过过滤器?

elasticsearch - 在Elastic search中创建别名的安全特权异常

c# - 如何在 C# Windows 窗体应用程序中激活拼写检查?

jsf - 如何在 p :inputTextarea Prime Faces? 中停用拼写检查

jquery - ASP.NET MVC 有拼写检查器吗?

elasticsearch - 是否可以使用FileBeat读取压缩文件(tar.gz)?

elasticsearch - Elasticsearch中时间序列数据的数据建模

javascript - 谷歌拼写检查 URI 不工作