Identity
domain.enrichment.entity.identity
Summary
Identity helpers for entity enrichment: text normalization, entity id derivation, candidate canonicalization, and entity state payload construction.
Functions
build_entity
Build the entity payload spread into pipeline state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str
|
Entity display name. |
required |
entity_type |
str
|
Entity type, defaults to |
'merchant'
|
entity_logo |
str | None
|
Logo URL/path, or |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
A payload mapping the |
dict
|
|
canonicalize_candidate
Canonicalize a candidate value for comparisons.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candidate |
str | None
|
Raw candidate string. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The normalized candidate key, or |
str | None
|
input. |
normalize_key
Normalize arbitrary text to a comparison key.
Applies NFKC unicode normalization, lower-cases, and strips surrounding whitespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text |
str | None
|
Text to normalize; |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The normalized key, or |
to_entity_id
Derive a stable slug id from a name.
Empty/falsy names yield None. Non-alphanumeric runs are replaced
with a single underscore and edge underscores are trimmed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name |
str | None
|
Entity name to slugify. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
str | None: The slug id, or |