gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 23:09:00 25 4
gpt4 key购买 nike

我已经熟悉 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 inthe dictionary. The default is 0.95, meaning 5% of the real words aremisspelled.

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com