المحلل القياسي
المحلل " standard " هو المحلل الافتراضي في Milvus، ويتم تطبيقه تلقائيًا على حقول النص إذا لم يتم تحديد محلل آخر. ويستخدم هذا المحلل تقطيع النص إلى رموز بناءً على القواعد النحوية، مما يجعله فعالًا لمعظم اللغات.
يُعد محلل « standard » مناسبًا للغات التي تعتمد على الفواصل (مثل المسافات وعلامات الترقيم) لتحديد حدود الكلمات. ومع ذلك، تحتاج لغات مثل الصينية والعربية والتايلاندية واليابانية والكورية إلى تقطيع أو توحيد خاص باللغة. في مثل هذه الحالات، استخدم محللًا خاصًا باللغة مثل chinese، arabic، أو thai، أو محللات مخصصة مع أدوات تجزئة متخصصة مثل lindera و icu.
التعريف
يتكون محلل « standard » من:
أداة التقطيع: تستخدم أداة التقطيع "
standard" لتقسيم النص إلى وحدات كلمات منفصلة بناءً على قواعد النحو. لمزيد من المعلومات، راجع أداة التقطيع القياسية.المرشح: يستخدم مرشح «
lowercase» لتحويل جميع الرموز إلى أحرف صغيرة، مما يتيح إجراء عمليات بحث لا تراعي تمييز الأحرف الكبيرة والصغيرة. لمزيد من المعلومات، راجع «الأحرف الصغيرة».
تتطابق وظائف محلل « standard » مع تكوين المحلل المخصص التالي:
analyzer_params = {
"tokenizer": "standard",
"filter": ["lowercase"]
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("tokenizer", "standard");
analyzerParams.put("filter", Collections.singletonList("lowercase"));
const analyzer_params = {
"tokenizer": "standard",
"filter": ["lowercase"]
};
analyzerParams := map[string]any{"tokenizer": "standard", "filter": []any{"lowercase"}}
# restful
analyzerParams='{
"tokenizer": "standard",
"filter": [
"lowercase"
]
}'
التكوين
لتطبيق محلل " standard " على حقل ما، ما عليك سوى تعيين " type " إلى " standard " في " analyzer_params"، وإدراج المعلمات الاختيارية حسب الحاجة.
analyzer_params = {
"type": "standard", # Specifies the standard analyzer type
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("type", "standard");
const analyzer_params = {
"type": "standard", // Specifies the standard analyzer type
}
analyzerParams = map[string]any{"type": "standard"}
# restful
analyzerParams='{
"type": "standard"
}'
يقبل محلل standard المعلمات الاختيارية التالية:
المعلمة |
الوصف |
|---|---|
|
مصفوفة تحتوي على قائمة بالكلمات الممنوعة، والتي سيتم إزالتها من عملية التقطيع إلى رموز. القيمة الافتراضية هي |
مثال على تكوين الكلمات الممنوعة المخصصة:
analyzer_params = {
"type": "standard", # Specifies the standard analyzer type
"stop_words", ["of"] # Optional: List of words to exclude from tokenization
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("type", "standard");
analyzerParams.put("stop_words", Collections.singletonList("of"));
analyzer_params = {
"type": "standard", // Specifies the standard analyzer type
"stop_words", ["of"] // Optional: List of words to exclude from tokenization
}
analyzerParams = map[string]any{"type": "standard", "stop_words": []string{"of"}}
# restful
بعد تعريف analyzer_params ، يمكنك تطبيقها على حقل VARCHAR عند تعريف مخطط المجموعة. يتيح ذلك لـ Milvus معالجة النص في هذا الحقل باستخدام المحلل المحدد من أجل التقطيع والتصفية بكفاءة. لمزيد من المعلومات، راجع مثال الاستخدام.
أمثلة
قبل تطبيق تكوين المحلل على مخطط المجموعة الخاص بك، تحقق من سلوكه باستخدام طريقة run_analyzer.
تكوين المحلل
analyzer_params = {
"type": "standard", # Standard analyzer configuration
"stop_words": ["for"] # Optional: Custom stop words parameter
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("type", "standard");
analyzerParams.put("stop_words", Collections.singletonList("for"));
// javascript
analyzerParams = map[string]any{"type": "standard", "stop_words": []string{"for"}}
# restful
analyzerParams='{
"type": "standard",
"stop_words": [
"of"
]
}'
التحقق باستخدام run_analyzer
from pymilvus import (
MilvusClient,
)
client = MilvusClient(
uri="http://localhost:19530",
token="root:Milvus"
)
# Sample text to analyze
sample_text = "The Milvus vector database is built for scale!"
# Run the standard analyzer with the defined configuration
result = client.run_analyzer(sample_text, analyzer_params)
print("Standard analyzer output:", result)
import io.milvus.v2.client.ConnectConfig;
import io.milvus.v2.client.MilvusClientV2;
import io.milvus.v2.service.vector.request.RunAnalyzerReq;
import io.milvus.v2.service.vector.response.RunAnalyzerResp;
ConnectConfig config = ConnectConfig.builder()
.uri("http://localhost:19530")
.token("root:Milvus")
.build();
MilvusClientV2 client = new MilvusClientV2(config);
List<String> texts = new ArrayList<>();
texts.add("The Milvus vector database is built for scale!");
RunAnalyzerResp resp = client.runAnalyzer(RunAnalyzerReq.builder()
.texts(texts)
.analyzerParams(analyzerParams)
.build());
List<RunAnalyzerResp.AnalyzerResult> results = resp.getResults();
// javascript
import (
"context"
"encoding/json"
"fmt"
"github.com/milvus-io/milvus/client/v2/milvusclient"
)
client, err := milvusclient.New(ctx, &milvusclient.ClientConfig{
Address: "localhost:19530",
APIKey: "root:Milvus",
})
if err != nil {
fmt.Println(err.Error())
// handle error
}
bs, _ := json.Marshal(analyzerParams)
texts := []string{"The Milvus vector database is built for scale!"}
option := milvusclient.NewRunAnalyzerOption(texts).
WithAnalyzerParams(string(bs))
result, err := client.RunAnalyzer(ctx, option)
if err != nil {
fmt.Println(err.Error())
// handle error
}
# restful
الناتج المتوقع
Standard analyzer output: ['the', 'milvus', 'vector', 'database', 'is', 'built', 'scale']