Stemmer
El filtro stemmer reduce las palabras a su forma base o raíz (lo que se conoce como stemming), lo que facilita la búsqueda de palabras con significados similares en distintas inflexiones. El filtro stemmer es compatible con varios idiomas, lo que permite realizar búsquedas e indexaciones eficaces en diversos contextos lingüísticos.
Configuración
El filtro stemmer es un filtro personalizado de Milvus. Para utilizarlo, especifique "type": "stemmer" en la configuración del filtro, junto con un parámetro language para seleccionar el idioma deseado para el stemming.
analyzer_params = {
"tokenizer": "standard",
"filter":[{
"type": "stemmer", # Specifies the filter type as stemmer
"language": "english", # Sets the language for stemming to English
}],
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("tokenizer", "standard");
analyzerParams.put("filter",
Collections.singletonList(
new HashMap<String, Object>() {{
put("type", "stemmer");
put("language", "english");
}}
)
);
const analyzer_params = {
"tokenizer": "standard",
"filter":[{
"type": "stemmer", // Specifies the filter type as stop
"language": "english",
}],
};
analyzerParams = map[string]any{"tokenizer": "standard",
"filter": []any{map[string]any{
"type": "stemmer",
"language": "english",
}}}
# restful
analyzerParams='{
"tokenizer": "standard",
"filter": [
{
"type": "stemmer",
"language": "english"
}
]
}'
El filtro stemmer acepta los siguientes parámetros configurables.
Parámetro |
Descripción |
|---|---|
|
Especifica el idioma para el proceso de stemming. Los idiomas admitidos son: |
El filtro stemmer opera sobre los términos generados por el tokenizador, por lo que debe utilizarse en combinación con un tokenizador.
Después de definir analyzer_params, puede aplicarlos a un campo VARCHAR al definir un esquema de colección. Esto permite a Milvus procesar el texto de ese campo utilizando el analizador especificado para una tokenización y filtrado eficientes. Para más detalles, consulte Ejemplo de uso.
Ejemplos
Antes de aplicar la configuración del analizador a su esquema de recopilación, verifique su comportamiento utilizando el método run_analyzer.
Configuración del analizador
analyzer_params = {
"tokenizer": "standard",
"filter":[{
"type": "stemmer", # Specifies the filter type as stemmer
"language": "english", # Sets the language for stemming to English
}],
}
Map<String, Object> analyzerParams = new HashMap<>();
analyzerParams.put("tokenizer", "standard");
analyzerParams.put("filter",
Collections.singletonList(
new HashMap<String, Object>() {{
put("type", "stemmer");
put("language", "english");
}}
)
);
// javascript
analyzerParams = map[string]any{"tokenizer": "standard",
"filter": []any{map[string]any{
"type": "stemmer",
"language": "english",
}}}
# restful
analyzerParams='{
"tokenizer": "standard",
"filter": [
{
"type": "stemmer",
"language": "english"
}
]
}'
Verificación mediante run_analyzerCompatible with Milvus 2.5.11+
# Sample text to analyze
sample_text = "running runs looked ran runner"
# Run the standard analyzer with the defined configuration
result = MilvusClient.run_analyzer(sample_text, analyzer_params)
print(result)
// java
// javascript
// go
# restful
not support yet
Salida esperada
['run', 'run', 'look', 'ran', 'runner']