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

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 を参照してください。アラビア語またはタイ語の辞書を確認するには、アラビア語のストップワードリスト または タイ語のストップワードリスト を参照してください。

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

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

例​

アナライザー設定をコレクションスキーマに適用する前に、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']
このページは役に立ちましたか?