gpt4 book ai didi

elasticsearch - Elasticsearch edge_ngram token_chars空格

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

有人可以告诉我Elasticsearch edge_ngram token_chars空格吗? Token_chars应该定义将包含在 token 中的符号。因此,如果我使用token_chars: ['letter', 'digit', 'whitespace'],在短语“2条红狐狸”的上下文中意味着什么?据我了解,它将以这种方式产生 token ['2','2','2 r','2 re','2 red'] 。我对标记没有在空格上分割,但是标记中会包含空格吗?
谢谢。

最佳答案

通常,您是对的,但它也取决于min_grammax_gram参数值。

看看下面。

范例1。
min_gram = 2max_gram = 10
制图

PUT /so54090009
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "my_tokenizer"
}
},
"tokenizer": {
"my_tokenizer": {
"type": "edge_ngram",
"min_gram": 2,
"max_gram": 10,
"token_chars": [
"letter",
"digit",
"whitespace"
]
}
}
}
}
}

分析
POST /so54090009/_analyze
{
"analyzer": "my_analyzer",
"text": "2 red foxes"
}

响应
{
"tokens": [
{
"token": "2 ",
"start_offset": 0,
"end_offset": 2,
"type": "word",
"position": 0
},
{
"token": "2 r",
"start_offset": 0,
"end_offset": 3,
"type": "word",
"position": 1
},
{
"token": "2 re",
"start_offset": 0,
"end_offset": 4,
"type": "word",
"position": 2
},
{
"token": "2 red",
"start_offset": 0,
"end_offset": 5,
"type": "word",
"position": 3
},
{
"token": "2 red ",
"start_offset": 0,
"end_offset": 6,
"type": "word",
"position": 4
},
{
"token": "2 red f",
"start_offset": 0,
"end_offset": 7,
"type": "word",
"position": 5
},
{
"token": "2 red fo",
"start_offset": 0,
"end_offset": 8,
"type": "word",
"position": 6
},
{
"token": "2 red fox",
"start_offset": 0,
"end_offset": 9,
"type": "word",
"position": 7
},
{
"token": "2 red foxe",
"start_offset": 0,
"end_offset": 10,
"type": "word",
"position": 8
}
]
}

示例2
min_gram = 1max_gram = 5
制图
PUT /so54090009
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "my_tokenizer"
}
},
"tokenizer": {
"my_tokenizer": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 5,
"token_chars": [
"letter",
"digit",
"whitespace"
]
}
}
}
}
}

分析
POST /so54090009/_analyze
{
"analyzer": "my_analyzer",
"text": "2 red foxes"
}

响应
{
"tokens": [
{
"token": "2",
"start_offset": 0,
"end_offset": 1,
"type": "word",
"position": 0
},
{
"token": "2 ",
"start_offset": 0,
"end_offset": 2,
"type": "word",
"position": 1
},
{
"token": "2 r",
"start_offset": 0,
"end_offset": 3,
"type": "word",
"position": 2
},
{
"token": "2 re",
"start_offset": 0,
"end_offset": 4,
"type": "word",
"position": 3
},
{
"token": "2 red",
"start_offset": 0,
"end_offset": 5,
"type": "word",
"position": 4
}
]
}

关于elasticsearch - Elasticsearch edge_ngram token_chars空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54090009/

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