中国語

chinese アナライザーは中国語テキストを処理するために特別に設計されており、効果的なセグメンテーションとトークン化を提供します。

定義

chinese アナライザーは次のように構成されます:

  • トークン化jieba トークナイザを使用して、語彙と文脈に基づいて中国語テキストをトークンにセグメンテーションする。詳細はJieba を参照。

  • フィルタcnalphanumonly フィルタを使用して、中国語以外の文字を含むトークンを削除します。詳細については、Cnalphanumonlyを参照してください。

chinese アナライザーの機能は、以下のカスタム・アナライザー・コンフィギュレーションと同等です:

analyzer_params = {
    "tokenizer": "jieba",
    "filter": ["cnalphanumonly"]
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("tokenizer", "jieba");
analyzerParams.put("filter", Collections.singletonList("cnalphanumonly"));
const analyzer_params = {
    "tokenizer": "jieba",
    "filter": ["cnalphanumonly"]
};
analyzerParams = map[string]any{"tokenizer": "jieba", "filter": []any{"cnalphanumonly"}}
# restful
analyzerParams='{
  "tokenizer": "jieba",
  "filter": [
    "cnalphanumonly"
  ]
}'

構成

chinese アナライザーをフィールドに適用するには、analyzer_paramstypechinese に設定するだけです。

analyzer_params = {
    "type": "chinese",
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("type", "chinese");
const analyzer_params = {
    "type": "chinese",
}
analyzerParams = map[string]any{"type": "chinese"}
# restful
analyzerParams='{
  "type": "chinese"
}'

chinese アナライザーはオプションのパラメーターを受け付けません。

アナライザーの設定をコレクション・スキーマに適用する前に、run_analyzer メソッドで動作を確認してください。

アナライザ構成

analyzer_params = {
    "type": "chinese",
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("type", "chinese");
// javascript
analyzerParams = map[string]any{"type": "chinese"}
# restful

を使用した検証run_analyzerCompatible with Milvus 2.5.11+

from pymilvus import (
    MilvusClient,
)

client = MilvusClient(uri="http://localhost:19530")

# Sample text to analyze
sample_text = "Milvus 是一个高性能、可扩展的向量数据库!"

# Run the standard analyzer with the defined configuration
result = client.run_analyzer(sample_text, analyzer_params)
print("English 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")
        .build();
MilvusClientV2 client = new MilvusClientV2(config);

List<String> texts = new ArrayList<>();
texts.add("Milvus 是一个高性能、可扩展的向量数据库!");

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{"Milvus 是一个高性能、可扩展的向量数据库!"}
option := milvusclient.NewRunAnalyzerOption(texts).
    WithAnalyzerParams(string(bs))

result, err := client.RunAnalyzer(ctx, option)
if err != nil {
    fmt.Println(err.Error())
    // handle error
}
# restful

期待される出力

Chinese analyzer output: ['Milvus', '是', '一个', '高性', '性能', '高性能', '可', '扩展', '的', '向量', '数据', '据库', '数据库']

Try Managed Milvus for Free

Zilliz Cloud is hassle-free, powered by Milvus and 10x faster.

Get Started
フィードバック

このページは役に立ちましたか ?