본문 바로가기
WIKI 기술 지식 베이스

Standard tokenizer

원문 보기 위키 갱신

출처: 문서

본문

표준 토크나이저

standard 토크나이저는 OpenSearch의 기본 토크나이저예요. 문자, 숫자, 구두점과 같은 다른 문자를 인식하는 문법 기반 접근법을 사용하여 단어 경계를 기준으로 텍스트를 토큰화해요. 유니코드 텍스트 분할 규칙(UAX#29)을 사용하여 텍스트를 토큰으로 나누기 때문에 매우 다재다능하고 여러 언어에 적합해요.

토큰화 규칙

standard 토크나이저는 Unicode Standard Annex #29: Unicode Text Segmentation에 정의된 단어 경계 규칙을 따라요. 다음 표는 이러한 규칙이 일반적인 입력에 어떻게 적용되는지 요약해요.

입력 규칙 토큰
fast, and scalable. 공백과 쉼표, 하이픈, 슬래시, +, #, %, @와 같은 대부분의 구두점은 텍스트를 분할하고 제거돼요. fast, and, scalable
can't, O'Neil 두 글자 사이의 아포스트로피는 단어를 분할하지 않아요. can't, O'Neil
end. Next 마침표 뒤에 공백이 오면 텍스트를 분할해요. end, Next
hello.world, U.S.A. 두 글자 사이의 마침표는 단어를 분할하지 않아요. 끝에 오는 마침표는 제거돼요. hello.world, U.S.A
3.5, 1,000, v1.2.3 두 숫자 사이의 마침표나 쉼표는 숫자를 분할하지 않아요. 3.5, 1,000, v1.2.3
snake_case 밑줄은 단어를 분할하지 않아요. snake_case
state-of-the-art 하이픈은 단어를 분할해요. state, of, the, art
[email protected] 이메일 주소는 @ 기호에서 분할돼요. admin, example.com
https://opensearch.org/docs URL은 콜론과 슬래시에서 분할돼요. https, opensearch.org, docs
東京, こんにちは 각 표의 문자와 히라가나 문자가 별도의 토큰이 돼요. 東, 京, こ, ん, に, ち, は

이메일 주소와 URL을 단일 토큰으로 유지하려면 uax_url_email 토크나이저를 사용하세요. max_token_length보다 긴 토큰은 해당 길이에서 분할돼요. 자세한 내용은 파라미터를 참조하세요.

사용 예시

다음 예제 요청은 my_index라는 새 인덱스를 생성하고 standard 토크나이저로 분석기를 구성해요.

PUT /my_index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "my_standard_analyzer": {
          "type": "standard"
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "content": {
        "type": "text",
        "analyzer": "my_standard_analyzer"
      }
    }
  }
}

{% include copy-curl.html %}

생성된 토큰

다음 요청을 사용하여 분석기를 사용해 생성된 토큰을 확인하세요.

POST /my_index/_analyze
{
  "analyzer": "my_standard_analyzer",
  "text": "OpenSearch is powerful, fast, and scalable."
}

{% include copy-curl.html %}

응답에는 생성된 토큰이 포함돼요.

{
  "tokens": [
    {
      "token": "opensearch",
      "start_offset": 0,
      "end_offset": 10,
      "type": "<ALPHANUM>",
      "position": 0
    },
    {
      "token": "is",
      "start_offset": 11,
      "end_offset": 13,
      "type": "<ALPHANUM>",
      "position": 1
    },
    {
      "token": "powerful",
      "start_offset": 14,
      "end_offset": 22,
      "type": "<ALPHANUM>",
      "position": 2
    },
    {
      "token": "fast",
      "start_offset": 24,
      "end_offset": 28,
      "type": "<ALPHANUM>",
      "position": 3
    },
    {
      "token": "and",
      "start_offset": 30,
      "end_offset": 33,
      "type": "<ALPHANUM>",
      "position": 4
    },
    {
      "token": "scalable",
      "start_offset": 34,
      "end_offset": 42,
      "type": "<ALPHANUM>",
      "position": 5
    }
  ]
}

Parameters

standard 토크나이저는 다음 파라미터로 구성할 수 있어요.

파라미터 필수/선택 데이터 타입 설명
max_token_length 선택 Integer 생성된 토큰의 최대 길이를 설정해요. 이 길이를 초과하면 토큰은 max_token_length에 설정된 길이에서 여러 토큰으로 분할돼요. 기본값은 255예요.

더 알아보기 (Learn more)