メインコンテンツまでスキップ

Stop

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

構成​

インラインリストで stop フィルターを使用するには、フィルター構成で "type": "stop" を指定し、ストップワードのリストを提供する stop_words パラメーターを併せて指定します。

python
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 つの方法があります:

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

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

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

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

    各定義済み辞書の正確な内容については、stop_words を参照してください。アラビア語またはタイ語の辞書を確認するには、Arabic stop-word list または Thai stop-word list を参照してください。

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

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

例​

アナライザー構成をコレクションスキーマに適用する前に、run_analyzer メソッドを使用してその動作を検証します。

アナライザー構成​

python
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 を使用した検証​

python
from pymilvus import (
MilvusClient,
)

client = MilvusClient(uri="YOUR_CLUSTER_ENDPOINT", token="YOUR_CLUSTER_TOKEN")

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

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

期待される出力​

plaintext
['The', 'stop', 'filter', 'allows', 'control', 'over', 'common', 'stop', 'words', 'text', 'processing']
このページは役に立ちましたか?