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

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はそのフィールドのテキストを指定されたアナライザーを使用して処理し、効率的なトークン化とフィルタリングを行うことができます。詳細については、使用例 を参照してください。

アナライザー設定をコレクションスキーマに適用する前に、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']