gpt4 book ai didi

elasticsearch - 如何在Elasticsearch中仅向前创建ngram?

转载 作者:行者123 更新时间:2023-12-03 01:13:34 24 4
gpt4 key购买 nike

是否可以像这样创建ngram:

homework -> ho,hom,home,homew,homewo,homewor,homework only ? 
哪个只是向前方向?
目前,它正在创建所有可能的方式。

最佳答案

The edge_ngram tokenizer first breaks text down into words whenever itencounters one of a list of specified characters, then it emitsN-grams of each word where the start of the N-gram is anchored to thebeginning of the word.


请引用此 official documentation以获取有关Edge n-gram的详细说明
索引映射:
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "my_tokenizer"
}
},
"tokenizer": {
"my_tokenizer": {
"type": "edge_ngram",
"min_gram": 2,
"max_gram": 10,
"token_chars": [
"letter",
"digit"
]
}
}
}
}
}
分析API
将生成以下 token :
{
"analyzer": "my_analyzer",
"text": "Homework"
}

tokens": [
{
"token": "Ho",
"start_offset": 0,
"end_offset": 2,
"type": "word",
"position": 0
},
{
"token": "Hom",
"start_offset": 0,
"end_offset": 3,
"type": "word",
"position": 1
},
{
"token": "Home",
"start_offset": 0,
"end_offset": 4,
"type": "word",
"position": 2
},
{
"token": "Homew",
"start_offset": 0,
"end_offset": 5,
"type": "word",
"position": 3
},
{
"token": "Homewo",
"start_offset": 0,
"end_offset": 6,
"type": "word",
"position": 4
},
{
"token": "Homewor",
"start_offset": 0,
"end_offset": 7,
"type": "word",
"position": 5
},
{
"token": "Homework",
"start_offset": 0,
"end_offset": 8,
"type": "word",
"position": 6
}
]
}
注意:如果要进行自动完成搜索,请引用此blog

关于elasticsearch - 如何在Elasticsearch中仅向前创建ngram?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63423787/

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