Impl
pipelines.enrichment.entity.impl
Summary
Concrete entity-family implementations (dagpipe stage nodes + root).
Stage bodies are ports of domain/enrichment/entity/resolver.py, keeping the
exact fork/confidence semantics. The root ImplEntityPipeline.enrich runs the
hexa-wired stage graph through a dagpipe Engine (assembled in
shared/loader.py) and delegates terminal processing to
ImplEntityFinalizePort (port of EntityStatesProcessorAdaptor).
Classes
ImplCandidateFlagsPort
Bases: CandidateFlagsPort
Candidate-flags stage: keyword matches append candidate-based flags.
Attributes
candidate_based_flag_mapping
property
Keyword → flag mapping used for candidate flagging.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The candidate-based flag mapping. |
config
property
Per-node config injected via set_config.
Returns:
| Type | Description |
|---|---|
|
dict | None: The per-node config, or None before injection. |
Functions
resolve
Append candidate flags whose keywords appear in the candidate value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state |
State
|
Incoming state carrying a candidate value and flags. |
required |
Yields:
| Name | Type | Description |
|---|---|---|
State |
Iterable[State]
|
A fork with updated |
set_config
Inject the per-node config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config |
dict
|
Per-node config from the dagpipe spec. |
required |
set_registry
Inject the merged pattern registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
registry |
PatternRegistry
|
The merged pattern registry. |
required |
ImplEntityAliasPort
Bases: EntityAliasPort
Entity-alias stage: resolve the entity from the candidate via aliases.
Attributes
config
property
Per-node config injected via set_config.
Returns:
| Type | Description |
|---|---|
|
dict | None: The per-node config, or None before injection. |
default_logo_mapping
property
Entity type → default logo mapping.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The default logo mapping. |
entity_alias_regex
property
Alias regex → name pairs used for entity resolution.
Returns:
| Type | Description |
|---|---|
|
List[Tuple[re.Pattern, str]]: Compiled (regex, name) pairs. |
entity_type_mapping
property
Entity id → type mapping used for entity resolution.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The entity type mapping. |
Functions
resolve
Resolve the entity from the candidate value via alias regexes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state |
State
|
Incoming state carrying a candidate value. |
required |
Yields:
| Name | Type | Description |
|---|---|---|
State |
Iterable[State]
|
A fork with the aliased entity payload, or the unmodified state when the name is already set or no alias matches. |
set_config
Inject the per-node config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config |
dict
|
Per-node config from the dagpipe spec. |
required |
set_registry
Inject the merged pattern registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
registry |
PatternRegistry
|
The merged pattern registry. |
required |
ImplEntityFinalizePort
Bases: EntityFinalizePort
Finalize terminal states into the entity result dict.
Functions
process
Build the entity result dict from the best terminal state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
states |
List
|
Terminal states from the dagpipe graph. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The entity result dict (name, id, type, logo, raw_candidate, candidate flags and tags). |
ImplEntityPipeline
Bases: EntityPipeline
Concrete entity pipeline root wiring the stage ports.
Attributes:
| Name | Type | Description |
|---|---|---|
normalize |
ImplNormalizePort
|
Normalize stage port. |
extract_candidates |
ImplExtractCandidatesPort
|
Extract-candidates port. |
candidate_flags |
ImplCandidateFlagsPort
|
Candidate-flags port. |
amount_flags |
ImplAmountFlagsPort
|
Amount-flags port. |
set_entity |
ImplSetEntityPort
|
Set-entity port. |
entity_alias |
ImplEntityAliasPort
|
Entity-alias port. |
fallback |
ImplFallbackPort
|
Fallback port. |
finalize |
ImplEntityFinalizePort
|
Terminal finalize port. |
Functions
enrich
Run the entity graph on a raw payload and finalize the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload |
dict
|
Raw transaction payload. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The entity result dict from the finalize port. |
ImplExtractCandidatesPort
Bases: ExtractCandidatesPort
Extract-candidates stage: signals → candidate value forks with penalties.
Attributes
candidate_regex
property
Candidate extraction regexes from the pattern registry.
Returns:
| Type | Description |
|---|---|
|
List[re.Pattern]: Compiled candidate extraction regexes. |
config
property
Per-node config injected via set_config.
Returns:
| Type | Description |
|---|---|
|
dict | None: The per-node config, or None before injection. |
negative_candidates
property
Tokens excluded from candidate extraction.
Returns:
| Name | Type | Description |
|---|---|---|
List |
The registered negative candidate tokens. |
Functions
resolve
Yield candidate-value forks from signals, penalizing fallbacks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state |
State
|
Incoming state carrying |
required |
Yields:
| Name | Type | Description |
|---|---|---|
State |
Iterable[State]
|
Forks carrying |
set_config
Inject the per-node config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config |
dict
|
Per-node config from the dagpipe spec. |
required |
set_registry
Inject the merged pattern registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
registry |
PatternRegistry
|
The merged pattern registry. |
required |
ImplFallbackPort
Bases: FallbackPort
Terminal fallback stage: candidate merchant/person, else Unknown.
Attributes
config
property
Per-node config injected via set_config.
Returns:
| Type | Description |
|---|---|
|
dict | None: The per-node config, or None before injection. |
Functions
resolve
Assign the terminal fallback entity when none was resolved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state |
State
|
Incoming terminal state. |
required |
Yields:
| Name | Type | Description |
|---|---|---|
State |
Iterable[State]
|
A fork carrying the fallback entity (candidate, Unknown, or the already-resolved entity). |
set_config
Inject the per-node config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config |
dict
|
Per-node config from the dagpipe spec. |
required |
set_registry
Inject the merged pattern registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
registry |
PatternRegistry
|
The merged pattern registry. |
required |
ImplNormalizePort
Bases: NormalizePort
Normalize stage: strip number sequences, then build raw/items/parts signals.
Attributes
config
property
Per-node config injected via set_config.
Returns:
| Type | Description |
|---|---|
|
dict | None: The per-node config, or None before injection. |
Functions
resolve
Clean raw.description and yield a single signals fork.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state |
State
|
Incoming state carrying |
required |
Yields:
| Name | Type | Description |
|---|---|---|
State |
Iterable[State]
|
A single fork populating |
set_config
Inject the per-node config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config |
dict
|
Per-node config from the dagpipe spec. |
required |
set_registry
Inject the merged pattern registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
registry |
PatternRegistry
|
The merged pattern registry. |
required |
ImplSetEntityPort
Bases: SetEntityPort
Set-entity stage: resolve the entity from candidate flags via rules.
Attributes
config
property
Per-node config injected via set_config.
Returns:
| Type | Description |
|---|---|
|
dict | None: The per-node config, or None before injection. |
default_logo_mapping
property
Entity type → default logo mapping.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The default logo mapping. |
entity_type_mapping
property
Entity id → type mapping used for entity resolution.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
The entity type mapping. |
flags_based_entity_rules
property
Flag-matching rules that emit the resolved entity.
Returns:
| Type | Description |
|---|---|
|
List[Dict]: The ordered entity rules. |
Functions
resolve
Resolve the entity from candidate flags using the first matching rule.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state |
State
|
Incoming state carrying candidate flags. |
required |
Yields:
| Name | Type | Description |
|---|---|---|
State |
Iterable[State]
|
A fork with the resolved entity payload, the unmodified state when an entity name is already set, or a penalized fork when unresolvable. |
set_config
Inject the per-node config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config |
dict
|
Per-node config from the dagpipe spec. |
required |
set_registry
Inject the merged pattern registry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
registry |
PatternRegistry
|
The merged pattern registry. |
required |