Kuromoji part of speech token filter
출처: 문서
본문
Kuromoji 품사 토큰 필터
kuromoji_part_of_speech 토큰 필터는 품사(POS) 태그가 설정된 중지 태그 목록의 항목과 일치하는 토큰을 제거해요. Kuromoji 토크나이저는 각 토큰에 IPAdic 품사 태그를 할당해요. 이 필터는 해당 태그를 읽고 내용 기능보다는 문법적 기능(예: 조사, 조동사, 구두점)을 수행하는 토큰을 폐기해요.
설치
kuromoji_part_of_speech 토큰 필터는 analysis-kuromoji 플러그인이 필요해요. 설치 방법은 Kuromoji 분석기를 참조하세요.
매개변수
다음 표는 kuromoji_part_of_speech 토큰 필터의 매개변수를 나열해요.
| 매개변수 | 데이터 유형 | 설명 |
|---|---|---|
stoptags |
Array of strings | 제거할 IPAdic 품사 태그 목록이에요. POS 태그가 이 목록의 항목과 정확히 일치하는 토큰은 폐기돼요. 기본값은 내장된 일본어 중지 태그 세트예요. |
사용 가능한 중지 태그의 전체 목록은 Lucene 저장소의 stoptags.txt를 참조하세요.
예: 기본 필터
다음 예제는 기본 중지 태그 목록을 사용하는 분석기로 인덱스를 생성해요.
PUT /kuromoji-pos-index
{
"settings": {
"analysis": {
"analyzer": {
"pos_filter_analyzer": {
"type": "custom",
"tokenizer": "kuromoji_tokenizer",
"filter": ["kuromoji_part_of_speech"]
}
}
}
}
}
{% include copy-curl.html %}
도쿄 레스토랑에서 초밥을 먹는다는 뜻의 문장으로 분석기를 테스트해요.
POST /kuromoji-pos-index/_analyze
{
"analyzer": "pos_filter_analyzer",
"text": "東京のレストランで寿司を食べる"
}
{% include copy-curl.html %}
응답은 조사 の(소유격), で(처소격), を(목적격)이 제거된 것을 보여줘요.
{
"tokens": [
{
"token": "東京",
"start_offset": 0,
"end_offset": 2,
"type": "word",
"position": 0
},
{
"token": "レストラン",
"start_offset": 3,
"end_offset": 8,
"type": "word",
"position": 2
},
{
"token": "寿司",
"start_offset": 9,
"end_offset": 11,
"type": "word",
"position": 4
},
{
"token": "食べる",
"start_offset": 12,
"end_offset": 15,
"type": "word",
"position": 6
}
]
}
예: 사용자 정의 중지 태그
다음 예제는 다른 모든 문법 토큰은 유지하면서 조동사(助動詞)만 제거하는 필터를 생성해요.
PUT /kuromoji-custom-pos-index
{
"settings": {
"analysis": {
"filter": {
"auxiliary_verb_filter": {
"type": "kuromoji_part_of_speech",
"stoptags": ["助動詞"]
}
},
"analyzer": {
"auxiliary_filter_analyzer": {
"type": "custom",
"tokenizer": "kuromoji_tokenizer",
"filter": ["auxiliary_verb_filter"]
}
}
}
}
}
{% include copy-curl.html %}