Skip to content

Latest commit

 

History

History
196 lines (188 loc) · 4.86 KB

6.5.2-uax-url-email.md

File metadata and controls

196 lines (188 loc) · 4.86 KB
description
이 문서의 허가되지 않은 무단 복제나 배포 및 출판을 금지합니다. 본 문서의 내용 및 도표 등을 인용하고자 하는 경우 출처를 명시하고 김종민([email protected])에게 사용 내용을 알려주시기 바랍니다.

6.5.2 UAX URL Email

주로 사용되는 Standard 토크나이저도 @, / 같은 특수문자는 공백과 마찬가지로 제거하고 분리합니다. 그런데 요즘의 블로그 포스트나 신문기사 같은 텍스트 들에는 이메일 주소 또는 웹 URL 경로 등이 삽입되어 있는 경우가 상당히 많습니다. 이 경우 Standard 토크나이저를 사용하면 이메일 주소등이 정상적으로 인식되지 않아 문제가 될 수 있는데, 이를 방지하기 위해 사용 가능한 것이 UAX URL Email 토크나이저 입니다.

UAX URL Email 토크나이저는 이메일 주소와 웹 URL 경로는 분리하지 않고 그대로 하나의 텀으로 저장을 합니다. 다음은 "email address is [email protected] and website is https://www.elastic.co" 문장을 각각 Standard 그리고 UAX URL Email 토크나이저로 분리 한 결과입니다.

{% tabs %} {% tab title="request" %} {% code title="standard 토크나이저로 문장 분석" %}

GET _analyze
{
  "tokenizer": "standard",
  "text": "email address is [email protected] and website is https://www.elastic.co"
}

{% endcode %} {% endtab %}

{% tab title="response" %} {% code title="standard 토크나이저로 문장 분석 결과" %}

{
  "tokens" : [
    {
      "token" : "email",
      "start_offset" : 0,
      "end_offset" : 5,
      "type" : "<ALPHANUM>",
      "position" : 0
    },
    {
      "token" : "address",
      "start_offset" : 6,
      "end_offset" : 13,
      "type" : "<ALPHANUM>",
      "position" : 1
    },
    {
      "token" : "is",
      "start_offset" : 14,
      "end_offset" : 16,
      "type" : "<ALPHANUM>",
      "position" : 2
    },
    {
      "token" : "my",
      "start_offset" : 17,
      "end_offset" : 19,
      "type" : "<ALPHANUM>",
      "position" : 3
    },
    {
      "token" : "name",
      "start_offset" : 20,
      "end_offset" : 24,
      "type" : "<ALPHANUM>",
      "position" : 4
    },
    {
      "token" : "email.com",
      "start_offset" : 25,
      "end_offset" : 34,
      "type" : "<ALPHANUM>",
      "position" : 5
    },
    {
      "token" : "and",
      "start_offset" : 35,
      "end_offset" : 38,
      "type" : "<ALPHANUM>",
      "position" : 6
    },
    {
      "token" : "website",
      "start_offset" : 39,
      "end_offset" : 46,
      "type" : "<ALPHANUM>",
      "position" : 7
    },
    {
      "token" : "is",
      "start_offset" : 47,
      "end_offset" : 49,
      "type" : "<ALPHANUM>",
      "position" : 8
    },
    {
      "token" : "https",
      "start_offset" : 50,
      "end_offset" : 55,
      "type" : "<ALPHANUM>",
      "position" : 9
    },
    {
      "token" : "www.elastic.co",
      "start_offset" : 58,
      "end_offset" : 72,
      "type" : "<ALPHANUM>",
      "position" : 10
    }
  ]
}

{% endcode %} {% endtab %} {% endtabs %}

{% tabs %} {% tab title="request" %} {% code title="uax_url_email 토크나이저로 문장 분석" %}

GET _analyze
{
  "tokenizer": "uax_url_email",
  "text": "email address is [email protected] and website is https://www.elastic.co"
}

{% endcode %} {% endtab %}

{% tab title="response" %} {% code title="letter 토크나이저로 문장 분석 결과" %}

{
  "tokens" : [
    {
      "token" : "email",
      "start_offset" : 0,
      "end_offset" : 5,
      "type" : "<ALPHANUM>",
      "position" : 0
    },
    {
      "token" : "address",
      "start_offset" : 6,
      "end_offset" : 13,
      "type" : "<ALPHANUM>",
      "position" : 1
    },
    {
      "token" : "is",
      "start_offset" : 14,
      "end_offset" : 16,
      "type" : "<ALPHANUM>",
      "position" : 2
    },
    {
      "token" : "[email protected]",
      "start_offset" : 17,
      "end_offset" : 34,
      "type" : "<EMAIL>",
      "position" : 3
    },
    {
      "token" : "and",
      "start_offset" : 35,
      "end_offset" : 38,
      "type" : "<ALPHANUM>",
      "position" : 4
    },
    {
      "token" : "website",
      "start_offset" : 39,
      "end_offset" : 46,
      "type" : "<ALPHANUM>",
      "position" : 5
    },
    {
      "token" : "is",
      "start_offset" : 47,
      "end_offset" : 49,
      "type" : "<ALPHANUM>",
      "position" : 6
    },
    {
      "token" : "https://www.elastic.co",
      "start_offset" : 50,
      "end_offset" : 72,
      "type" : "<URL>",
      "position" : 7
    }
  ]
}

{% endcode %} {% endtab %} {% endtabs %}

"tokenizer": "uax_url_email" 로 설정하여 텍스트를 분석하면 이메일 주소와 웹 URL은 그대로 남아있는 것을 확인할 수 있습니다.