メインコンテンツまでスキップ
バージョン: User Guides (BYOC)

Stop

stop フィルターは、トークン化されたテキストから指定されたストップワードを削除し、一般的で意味の薄い単語を除去するのに役立ちます。stop_words パラメーターを使用して、ストップワードのリストを設定できます。

設定

stop フィルターは Zilliz Cloud におけるカスタムフィルターです。これを使用するには、フィルターの設定で "type": "stop" を指定し、stop_words パラメーターでストップワードのリストを提供します。

analyzer_params = {
"tokenizer": "standard",
"filter":[{
"type": "stop", # Specifies the filter type as stop
"stop_words": ["of", "to", "_english_"], # Defines custom stop words and includes the English stop word list
}],
}

stop フィルターは、以下の設定可能なパラメータを受け入れます。

パラメータ

説明

stop_words

トークナイズから除外する単語のリスト。デフォルトでは、このフィルターは組み込みの english 辞書を使用します。これを上書きまたは拡張する方法は以下の3つです:

  • 組み込み辞書 – 事前定義された辞書を使用するには、以下の言語エイリアスのいずれかを指定します:

    "english", "danish", "dutch", "finnish", "french", "german", "hungarian", "italian", "norwegian", "portuguese", "russian", "spanish", "swedish"

  • カスタムリスト – 自分で定義した用語の配列を渡します(例: ["foo", "bar", "baz"])。

  • 混合リスト – エイリアスとカスタム用語を組み合わせます(例: ["of", "to", "english"])。

    各事前定義辞書の正確な内容については、stop_words を参照してください。

stop フィルターはトークナイザーによって生成された用語に対して動作するため、トークナイザーと組み合わせて使用する必要があります。Zilliz Cloud で利用可能なトークナイザーの一覧については、トークナイザー Reference を参照してください。

analyzer_params を定義したら、コレクションスキーマを定義する際に VARCHAR フィールドに適用できます。これにより、Zilliz Cloud はそのフィールド内のテキストを指定されたアナライザーを使って処理し、効率的なトークン化とフィルタリングを実現します。詳細については、Example use を参照してください。

コレクションスキーマにアナライザー設定を適用する前に、run_analyzer メソッドを使ってその動作を検証してください。

アナライザー設定

analyzer_params = {
"tokenizer": "standard",
"filter":[{
"type": "stop", # Specifies the filter type as stop
"stop_words": ["of", "to", "_english_"], # Defines custom stop words and includes the English stop word list
}],
}

run_analyzer を使用した検証

from pymilvus import (
MilvusClient,
)

client = MilvusClient(uri="YOUR_CLUSTER_ENDPOINT")

# Sample text to analyze
sample_text = "The stop filter allows control over common stop words for text processing."

# Run the standard analyzer with the defined configuration
result = client.run_analyzer(sample_text, analyzer_params)
print("Standard analyzer output:", result)

期待される出力

['The', 'stop', 'filter', 'allows', 'control', 'over', 'common', 'stop', 'words', 'text', 'processing']