7.9.5. TokenFilterStopWord#

7.9.5.1. 概要#

TokenFilterStopWord は、文書を検索する時にトークナイズされたトークンからストップワードを除去します。

TokenFilterStopWord は、文書を検索する時のみトークン除去するため、文書を追加した後でストップワードを指定することもできます。

column オプションを指定しない場合、ストップワードは、語彙表の is_stop_word カラムで指定されます。

7.9.5.2. 構文#

TokenFilterStopWord は、省略可能な引数があります。

TokenFilterStopWord

TokenFilterStopWord("column", "ignore")

7.9.5.3. 使い方#

以下は TokenFilterStopWord トークンフィルターを使う例です。

実行例:

plugin_register token_filters/stop_word
# [[0,1337566253.89858,0.000355720520019531],true]
table_create Memos TABLE_NO_KEY
# [[0,1337566253.89858,0.000355720520019531],true]
column_create Memos content COLUMN_SCALAR ShortText
# [[0,1337566253.89858,0.000355720520019531],true]
table_create Terms TABLE_PAT_KEY ShortText \
  --default_tokenizer TokenBigram \
  --normalizer NormalizerAuto \
  --token_filters TokenFilterStopWord
# [[0,1337566253.89858,0.000355720520019531],true]
column_create Terms memos_content COLUMN_INDEX|WITH_POSITION Memos content
# [[0,1337566253.89858,0.000355720520019531],true]
column_create Terms is_stop_word COLUMN_SCALAR Bool
# [[0,1337566253.89858,0.000355720520019531],true]
load --table Terms
[
{"_key": "and", "is_stop_word": true}
]
# [[0,1337566253.89858,0.000355720520019531],1]
load --table Memos
[
{"content": "Hello"},
{"content": "Hello and Good-bye"},
{"content": "Good-bye"}
]
# [[0,1337566253.89858,0.000355720520019531],3]
select Memos --match_columns content --query "Hello and"
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         2
#       ],
#       [
#         [
#           "_id",
#           "UInt32"
#         ],
#         [
#           "content",
#           "ShortText"
#         ]
#       ],
#       [
#         1,
#         "Hello"
#       ],
#       [
#         2,
#         "Hello and Good-bye"
#       ]
#     ]
#   ]
# ]

and というトークンは Terms テーブルでストップワードと指定されています。

"Hello" は文書内に and がありませんがマッチしています。なぜなら、 and はストップワードと指定されているため、クエリーから除去されているからです。

以下のように columns オプションを使って is_stop_columns 以外のカラムをストップワードに指定できます。

実行例:

plugin_register token_filters/stop_word
# [[0,1337566253.89858,0.000355720520019531],true]
table_create Memos TABLE_NO_KEY
# [[0,1337566253.89858,0.000355720520019531],true]
column_create Memos content COLUMN_SCALAR ShortText
# [[0,1337566253.89858,0.000355720520019531],true]
table_create Terms TABLE_PAT_KEY ShortText \
  --default_tokenizer TokenBigram \
  --normalizer NormalizerAuto \
  --token_filters 'TokenFilterStopWord("column", "ignore")'
# [[0,1337566253.89858,0.000355720520019531],true]
column_create Terms memos_content COLUMN_INDEX|WITH_POSITION Memos content
# [[0,1337566253.89858,0.000355720520019531],true]
column_create Terms ignore COLUMN_SCALAR Bool
# [[0,1337566253.89858,0.000355720520019531],true]
load --table Terms
[
{"_key": "and", "ignore": true}
]
# [[0,1337566253.89858,0.000355720520019531],1]
load --table Memos
[
{"content": "Hello"},
{"content": "Hello and Good-bye"},
{"content": "Good-bye"}
]
# [[0,1337566253.89858,0.000355720520019531],3]
select Memos --match_columns content --query "Hello and"
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         2
#       ],
#       [
#         [
#           "_id",
#           "UInt32"
#         ],
#         [
#           "content",
#           "ShortText"
#         ]
#       ],
#       [
#         1,
#         "Hello"
#       ],
#       [
#         2,
#         "Hello and Good-bye"
#       ]
#     ]
#   ]
# ]

7.9.5.4. 引数#

7.9.5.4.1. 省略可能引数#

省略可能な引数 columns があります。

7.9.5.4.1.1. columns#

ストップワードを指定するカラムを指定します。