decompound_mode
decompound_mode는 토크나이저가 복합명사를 처리하는 방식을 결정한다. 복합명사가 있을 경우 단어를 어떻게 쪼갤지 결정한다.
파라미터값 | 설명 | 예제 |
---|---|---|
none | 복합명사로 분리하지 않는다 | 월미도 영종도 |
discard | 복합명사로 분리하고 원본 데이터는 삭제한다 | 잠실역=>[잠실,역] |
mixed | 복합명사로 분리하고 원본 데이터는 유지한다 | 잠실역=>[잠실,역,잠실역] |
nori_analyzer 인덱스 생성 (decompound_mode = mixed)
PUT http://localhost:9200/nori_analyzer
content-Type: application/json
{
"settings": {
"index": {
"analysis": {
"tokenizer": {
"nori_tokenizer": {
"type": "nori_tokenizer",
"decompound_mode": "mixed"
}
},
"analyzer": {
"nori_token_analyzer": {
"type": "custom",
"tokenizer": "nori_tokenizer"
}
}
}
}
}
}
nori_analyzer 인덱스에 nori_token_analyzer 테스트
POST http://localhost:9200/nori_analyzer/_analyze
content-Type: application/json
{
"analyzer": "nori_token_analyzer",
"text": "잠실역"
}
[결과]
{
"tokens": [
{
"token": "잠실역",
"start_offset": 0,
"end_offset": 3,
"type": "word",
"position": 0,
"positionLength": 2
},
{
"token": "잠실",
"start_offset": 0,
"end_offset": 2,
"type": "word",
"position": 0
},
{
"token": "역",
"start_offset": 2,
"end_offset": 3,
"type": "word",
"position": 1
}
]
}
decompound_mode = discard로 생성하면
[결과]
{
"tokens": [
{
"token": "잠실",
"start_offset": 0,
"end_offset": 2,
"type": "word",
"position": 0
},
{
"token": "역",
"start_offset": 2,
"end_offset": 3,
"type": "word",
"position": 1
}
]
}
decompound_mode = none으로 생성하면
[결과]
{
"tokens": [
{
"token": "잠실역",
"start_offset": 0,
"end_offset": 3,
"type": "word",
"position": 0
}
]
}
반응형