Skip to main content

normalize_entity_name

Function normalize_entity_name 

Source
pub fn normalize_entity_name(s: &str) -> String
Expand description

Normalizes an entity name to kebab-case ASCII.

Applies NFKD decomposition, filters to ASCII (transliterating by dropping diacritical combining marks), lowercases, converts spaces and underscores to hyphens, collapses consecutive hyphens, and trims leading/trailing hyphens.

ยงExamples

use sqlite_graphrag::parsers::normalize_entity_name;

assert_eq!(normalize_entity_name("Danilo Aguiar"), "danilo-aguiar");
assert_eq!(normalize_entity_name("CANONICAL_RELATIONS"), "canonical-relations");
assert_eq!(normalize_entity_name("  hello  world  "), "hello-world");
assert_eq!(normalize_entity_name("danilo-aguiar"), "danilo-aguiar"); // idempotent