الطول
يقوم عامل التصفية length بإزالة الرموز التي لا تفي بمتطلبات الطول المحددة، مما يسمح لك بالتحكم في طول الرموز التي يتم الاحتفاظ بها أثناء معالجة النص.
التكوين
عامل التصفية length هو عامل تصفية مخصص في ميلفوس، يتم تحديده من خلال الإعداد "type": "length" في تكوين عامل التصفية. يمكنك تكوينه كقاموس داخل analyzer_params لتحديد حدود الطول.
analyzer_params = {
"tokenizer": "standard",
"filter":[{
"type": "length", # Specifies the filter type as length
"max": 10, # Sets the maximum token length to 10 characters
}],
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("tokenizer", "standard");
analyzerParams.put("filter",
Collections.singletonList(new HashMap<String, Object>() {{
put("type", "length");
put("max", 10);
}}));
cosnt analyzer_params = {
"tokenizer": "standard",
"filter":[{
"type": "length", # Specifies the filter type as length
"max": 10, # Sets the maximum token length to 10 characters
}],
};
analyzerParams = map[string]any{"tokenizer": "standard",
"filter": []any{map[string]any{
"type": "length",
"max": 10,
}}}
# restful
analyzerParams='{
"tokenizer": "standard",
"filter": [
{
"type": "length",
"max": 10
}
]
}'
يقبل عامل التصفية length المعلمات التالية القابلة للتكوين.
المعلمة |
الوصف |
|---|---|
|
يضبط الحد الأقصى لطول الرمز المميز. تتم إزالة الرموز الأطول من هذا الطول. |
يعمل عامل التصفية length على المصطلحات التي تم إنشاؤها بواسطة أداة الترميز، لذلك يجب استخدامه مع أداة ترميز. للحصول على قائمة بأدوات الترميز المتوفرة في ميلفوس، راجع أداة الترميز القياسية وصفحاتها الشقيقة.
بعد تحديد analyzer_params ، يمكنك تطبيقها على حقل VARCHAR عند تحديد مخطط المجموعة. يسمح ذلك لـ Milvus بمعالجة النص في ذلك الحقل باستخدام المحلل المحدد من أجل ترميز وتصفية فعالة. للحصول على التفاصيل، راجع أمثلة الاستخدام.
أمثلة
قبل تطبيق تكوين المحلل على مخطط المجموعة الخاص بك، تحقق من سلوكه باستخدام الأسلوب run_analyzer.
تكوين المحلّل
analyzer_params = {
"tokenizer": "standard",
"filter":[{
"type": "length", # Specifies the filter type as length
"max": 10, # Sets the maximum token length to 10 characters
}],
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("tokenizer", "standard");
analyzerParams.put("filter",
Collections.singletonList(new HashMap<String, Object>() {{
put("type", "length");
put("max", 10);
}}));
// javascript
analyzerParams = map[string]any{"tokenizer": "standard",
"filter": []any{map[string]any{
"type": "length",
"max": 10,
}}}
# restful
التحقق باستخدام run_analyzerCompatible with Milvus 2.5.11+
# Sample text to analyze
sample_text = "The length filter allows control over token length requirements for text processing."
# Run the standard analyzer with the defined configuration
result = MilvusClient.run_analyzer(sample_text, analyzer_params)
print(result)
// java
// javascript
// go
# restful
المخرجات المتوقعة
['The', 'length', 'filter', 'allows', 'control', 'over', 'token', 'length', 'for', 'text', 'processing']