Utils
pipelines.enrichment.shared.utils
Summary
Description/candidate utilities (port of domain/enrichment/entity/utils.py).
Functions
extract_candidates
Extract valid payee candidates from a description.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
description |
str
|
Raw description text. |
required |
candidate_regexes |
Iterable[Pattern]
|
Compiled extraction regexes. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: The normalized valid candidates. |
is_valid_candidate
Return True when a candidate looks like a plausible payee.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candidate |
str
|
Extracted candidate value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True when the candidate passes the length/content heuristics. |
lookup_mapping
Look up mapping values for a candidate token.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candidate |
str
|
Candidate token. |
required |
mapping |
dict
|
Mapping dict of key → MappingValue. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
list |
Matching value names, or |
normalize_description
Normalize a description: separators → space, lowercase, drop OCR noise.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text |
str
|
Raw description. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The normalized lowercase description. |
normalize_money_str
Format a numeric value as a fixed two-decimal string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x |
float
|
Value coercible to float. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The value formatted to exactly two decimals. |
normalize_person_handle
Normalize a person/UPI handle into a capitalized display name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle |
str
|
Raw handle (may carry a UPI suffix or trailing digits). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The cleaned handle, or "" when only hex characters remain. |
remove_number_sequence
Strip amount/balance digit sequences from a description.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text |
str
|
Description text. |
required |
amt |
str
|
Amount value. |
required |
bal |
str
|
Balance value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The cleaned, whitespace-collapsed description. |