ICUCompatible with Milvus 2.5.11+

icu 토큰화 도구는 소프트웨어 국제화를 위한 핵심 도구를 제공하는 유니코드 국제화 구성요소 (ICU) 오픈 소스 프로젝트를 기반으로 합니다. ICU의 단어 분리 알고리즘을 사용하여 토큰화 도구는 전 세계 대부분의 언어에서 텍스트를 단어로 정확하게 분할할 수 있습니다.

icu 토큰화 도구는 출력에서 구두점과 공백을 별도의 토큰으로 보존합니다. 예를 들어 "Привет! Как дела?"["Привет", "!", " ", "Как", " ", "дела", "?"] 이 됩니다. 이러한 독립형 구두점 토큰을 제거하려면 removepunct 필터를 사용합니다.

구성

icu 토큰화기를 사용하여 분석기를 구성하려면 analyzer_params 에서 tokenizericu 로 설정합니다.

analyzer_params = {
    "tokenizer": "icu",
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("tokenizer", "icu");
// node
analyzerParams = map[string]any{"tokenizer": "icu"}
# curl

icu 토큰화 도구는 하나 이상의 필터와 함께 사용할 수 있습니다. 예를 들어, 다음 코드는 icu 토큰라이저를 사용하고 구두점 필터를 제거하는 분석기를 정의합니다:

analyzer_params = {
    "tokenizer": "icu",
    "filter": ["removepunct"]
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("tokenizer", "icu");
analyzerParams.put("filter", Collections.singletonList("removepunct"));
// node
analyzerParams = map[string]any{"tokenizer": "icu", "filter": []string{"removepunct"}}
# curl

analyzer_params 을 정의한 후 컬렉션 스키마를 정의할 때 VARCHAR 필드에 적용할 수 있습니다. 이렇게 하면 Milvus가 지정된 분석기를 사용하여 해당 필드의 텍스트를 처리하여 효율적인 토큰화 및 필터링을 수행할 수 있습니다. 자세한 내용은 사용 예시를 참조하세요.

예제

분석기 구성을 컬렉션 스키마에 적용하기 전에 run_analyzer 메서드를 사용하여 그 동작을 확인하세요.

분석기 구성

analyzer_params = {
    "tokenizer": "icu",
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("tokenizer", "icu");
// node
analyzerParams = map[string]any{"tokenizer": "icu"}
# curl

다음을 사용하여 확인 run_analyzer

from pymilvus import (
    MilvusClient,
)

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

# Sample text to analyze
sample_text = "Привет! Как дела?"

# 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")
        .build();
MilvusClientV2 client = new MilvusClientV2(config);

List<String> texts = new ArrayList<>();
texts.add("Привет! Как дела?");

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{"Привет! Как дела?"}
option := milvusclient.NewRunAnalyzerOption(texts).
    WithAnalyzerParams(string(bs))

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

예상 출력

['Привет', '!', ' ', 'Как', ' ', 'дела', '?']

Try Managed Milvus for Free

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

Get Started
피드백

이 페이지가 도움이 되었나요?