ASCII folding
asciifolding フィルターは、Basic Latin Unicode block(最初の 127 個の ASCII 文字)外の文字を対応する ASCII 文字に変換します。たとえば、í のような文字を i に変換し、特に多言語コンテンツにおけるテキスト処理をよりシンプルで一貫性のあるものにします。
Configuration
asciifolding フィルターは Zilliz Cloud に組み込まれています。使用するには、analyzer_params 内の filter セクションでその名前を指定するだけです。
- Python
- Java
- NodeJS
- Go
- cURL
- C++
python
analyzer_params = {
"tokenizer": "standard",
"filter": ["asciifolding"],
}
java
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("tokenizer", "standard");
analyzerParams.put("filter", Collections.singletonList("asciifolding"));
javascript
const analyzer_params = {
"tokenizer": "standard",
"filter": ["asciifolding"],
};
go
analyzerParams = map[string]any{"tokenizer": "standard", "filter": []any{"asciifolding"}}
bash
# restful
analyzerParams='{
"tokenizer": "standard",
"filter": [
"asciifolding"
]
}'
c++
nlohmann::json analyzer_params = {
{"tokenizer", "standard"},
{"filter", {"asciifolding"}}
};
asciifolding フィルターは tokenizer によって生成された term に対して動作するため、tokenizer と組み合わせて使用する必要があります。Zilliz Cloud で使用可能な tokenizer の一覧については、Standard Tokenizer および関連ページを参照してください。
analyzer_params を定義した後、collection schema を定義する際にそれらを VARCHAR フィールドへ適用できます。これにより、Zilliz Cloud は指定された analyzer を使用してそのフィールド内のテキストを処理し、効率的な tokenization と filtering を実行できます。詳細については、Example use を参照してください。
Examples
analyzer 設定を collection schema に適用する前に、run_analyzer メソッドを使用してその動作を確認してください。
Analyzer configuration
- Python
- Java
- NodeJS
- Go
- cURL
- C++
python
analyzer_params = {
"tokenizer": "standard",
"filter": ["asciifolding"],
}
java
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("tokenizer", "standard");
analyzerParams.put("filter", Collections.singletonList("asciifolding"));
javascript
// javascript
go
analyzerParams = map[string]any{"tokenizer": "standard", "filter": []any{"asciifolding"}}
bash
# restful
c++
nlohmann::json analyzer_params = {
{"tokenizer", "standard"},
{"filter", {"asciifolding"}}
};
Verification using run_analyzer
- Python
- Java
- NodeJS
- Go
- cURL
- C++
python
from pymilvus import (
MilvusClient,
)
client = MilvusClient(
uri="YOUR_CLUSTER_ENDPOINT",
token="YOUR_CLUSTER_TOKEN"
)
# Sample text to analyze
sample_text = "Café Möller serves crème brûlée and piñatas."
# Run the standard analyzer with the defined configuration
result = client.run_analyzer(sample_text, analyzer_params)
print("Standard analyzer output:", result)
java
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("YOUR_CLUSTER_ENDPOINT")
.token("YOUR_CLUSTER_TOKEN")
.build();
MilvusClientV2 client = new MilvusClientV2(config);
List<String> texts = new ArrayList<>();
texts.add("Café Möller serves crème brûlée and piñatas.");
RunAnalyzerResp resp = client.runAnalyzer(RunAnalyzerReq.builder()
.texts(texts)
.analyzerParams(analyzerParams)
.build());
List<RunAnalyzerResp.AnalyzerResult> results = resp.getResults();
javascript
// javascript
go
import (
"context"
"encoding/json"
"fmt"
"github.com/milvus-io/milvus/client/v2/milvusclient"
)
client, err := milvusclient.New(ctx, &milvusclient.ClientConfig{
Address: "YOUR_CLUSTER_ENDPOINT",
APIKey: "YOUR_CLUSTER_TOKEN",
})
if err != nil {
fmt.Println(err.Error())
// handle error
}
bs, _ := json.Marshal(analyzerParams)
texts := []string{"Café Möller serves crème brûlée and piñatas."}
option := milvusclient.NewRunAnalyzerOption(texts).
WithAnalyzerParams(string(bs))
result, err := client.RunAnalyzer(ctx, option)
if err != nil {
fmt.Println(err.Error())
// handle error
}
bash
# restful
c++
#include "milvus/MilvusClientV2.h"
auto client = milvus::MilvusClientV2::Create();
milvus::ConnectParam connect_param{"YOUR_CLUSTER_ENDPOINT", "YOUR_CLUSTER_TOKEN"};
auto status = client->Connect(connect_param);
if (!status.IsOk()) {
std::cout << status.Message() << std::endl;
}
std::string text = "Café Möller serves crème brûlée and piñatas.";
auto request = milvus::RunAnalyzerRequest()
.AddText(text)
.WithAnalyzerParams(analyzer_params);
milvus::RunAnalyzerResponse response;
status = client->RunAnalyzer(request, response);
if (!status.IsOk()) {
std::cout << status.Message() << std::endl;
}
Expected output
python
['Cafe', 'Moller', 'serves', 'creme', 'brulee', 'and', 'pinatas']