泰语分词器
thai
分词器用于对泰语文本进行分词。由于泰语单词之间没有空格分隔,分词器必须根据特定语言规则识别词的边界。
使用示例
以下示例请求将创建一个名为 thai_index
的新索引,并使用 thai
分词器配置一个分析器。
PUT /thai_index
{
"settings": {
"analysis": {
"tokenizer": {
"thai_tokenizer": {
"type": "thai"
}
},
"analyzer": {
"thai_analyzer": {
"type": "custom",
"tokenizer": "thai_tokenizer"
}
}
}
},
"mappings": {
"properties": {
"content": {
"type": "text",
"analyzer": "thai_analyzer"
}
}
}
}
生成的词元
使用以下请求检查使用该分析器生成的词元
POST /thai_index/_analyze
{
"analyzer": "thai_analyzer",
"text": "ฉันชอบไปเที่ยวที่เชียงใหม่"
}
响应包含生成的词元
{
"tokens": [
{
"token": "ฉัน",
"start_offset": 0,
"end_offset": 3,
"type": "word",
"position": 0
},
{
"token": "ชอบ",
"start_offset": 3,
"end_offset": 6,
"type": "word",
"position": 1
},
{
"token": "ไป",
"start_offset": 6,
"end_offset": 8,
"type": "word",
"position": 2
},
{
"token": "เที่ยว",
"start_offset": 8,
"end_offset": 14,
"type": "word",
"position": 3
},
{
"token": "ที่",
"start_offset": 14,
"end_offset": 17,
"type": "word",
"position": 4
},
{
"token": "เชียงใหม่",
"start_offset": 17,
"end_offset": 26,
"type": "word",
"position": 5
}
]
}