Interpretation¶
interpretation ¶
Interpretation data contracts and mapping-backed implementation.
This is the package's public anchor module; it also exposes the distribution
version as __version__ (the fortune_telling_core package root belongs to
the sibling fortune-telling-core package, so this layer cannot own it there).
InterpretationKey
dataclass
¶
Lookup key for interpretation text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol_id
|
str
|
Symbol identifier to interpret. |
required |
position_id
|
str | None
|
Optional spread position identifier. |
None
|
variant
|
str | None
|
Optional engine-specific variant such as |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
to_dict ¶
Serialize the key to a JSON-compatible dictionary.
Source code in src/fortune_telling_core/interpretation.py
from_dict
classmethod
¶
Deserialize an interpretation key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
JsonMapping
|
JSON-compatible key mapping. |
required |
Returns:
| Type | Description |
|---|---|
InterpretationKey
|
The decoded key. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If required fields are missing or malformed. |
Source code in src/fortune_telling_core/interpretation.py
InterpretationEntry
dataclass
¶
InterpretationEntry(key: InterpretationKey, text: str, keywords: Sequence[str] = (), source: str | None = None)
Textual interpretation for one lookup key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
InterpretationKey
|
Lookup key this entry answers. |
required |
text
|
str
|
Interpretation text. |
required |
keywords
|
Sequence[str]
|
Search or summary keywords. |
()
|
source
|
str | None
|
Optional citation or dataset source. |
None
|
Raises:
| Type | Description |
|---|---|
ValidationError
|
If |
to_dict ¶
Serialize the entry to a JSON-compatible dictionary.
Source code in src/fortune_telling_core/interpretation.py
from_dict
classmethod
¶
Deserialize an interpretation entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
JsonMapping
|
JSON-compatible entry mapping. |
required |
Returns:
| Type | Description |
|---|---|
InterpretationEntry
|
The decoded entry. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If required fields are missing or malformed. |
Source code in src/fortune_telling_core/interpretation.py
InterpretationData ¶
Bases: Protocol
Protocol for interpretation lookup datasets.
lookup ¶
Return the best matching interpretation entry for key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
InterpretationKey
|
Desired symbol, position, and variant combination. |
required |
Returns:
| Type | Description |
|---|---|
InterpretationEntry | None
|
A matching entry, or |
Source code in src/fortune_telling_core/interpretation.py
LocaleDatasetLookup ¶
LocaleInterpretationRegistry ¶
Bases: Protocol
Registry protocol implemented by InterpretationRegistry.
MappingInterpretationData
dataclass
¶
Mapping-backed interpretation dataset with fallback lookup.
Lookup order is exact key, symbol plus variant, symbol plus position, then symbol only.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
Stable dataset identifier. |
required |
entries
|
Sequence[InterpretationEntry]
|
Interpretation entries in the dataset. |
required |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the id is empty or keys are duplicated. |
lookup ¶
Look up an interpretation with graceful fallbacks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
InterpretationKey
|
Desired symbol, position, and variant combination. |
required |
Returns:
| Type | Description |
|---|---|
InterpretationEntry | None
|
The first matching entry in the fallback chain, or |
Source code in src/fortune_telling_core/interpretation.py
to_dict ¶
Serialize the dataset to a JSON-compatible dictionary.
from_dict
classmethod
¶
Deserialize a mapping-backed interpretation dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
JsonMapping
|
JSON-compatible dataset mapping. |
required |
Returns:
| Type | Description |
|---|---|
MappingInterpretationData
|
The decoded dataset. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If required fields are missing or malformed. |
Source code in src/fortune_telling_core/interpretation.py
interpret ¶
interpret(reading: Reading, dataset_or_registry: object | Sequence[object], *, locale: str = 'en-GB') -> dict[str, InterpretationEntry]
Resolve interpretation entries for a structural core reading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reading
|
Reading
|
Core reading produced by a structural engine. |
required |
dataset_or_registry
|
object | Sequence[object]
|
One dataset, one locale-aware registry, or a sequence of datasets/registries to compose. |
required |
locale
|
str
|
Requested locale when a registry is supplied. |
'en-GB'
|
Returns:
| Type | Description |
|---|---|
dict[str, InterpretationEntry]
|
Mapping from spread position id to resolved interpretation entry. |
Source code in src/fortune_telling_core/interpretation.py
interpret_extras ¶
interpret_extras(reading: Reading, dataset_or_registry: object | Sequence[object], *, locale: str = 'en-GB') -> list[tuple[Selection, InterpretationEntry | None]]
Resolve interpretation entries for a reading's off-grid extras.
A reading's draw.extras holds structured selections not bound to a spread
position (e.g. astrology aspects, keyed astro.aspect.<type>), so they fall
outside :func:interpret. This resolves each by its symbol_id (a
kind modifier, when present, is tried as a variant first).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reading
|
Reading
|
Core reading produced by a structural engine. |
required |
dataset_or_registry
|
object | Sequence[object]
|
One dataset, one locale-aware registry, or a sequence of datasets/registries to compose. |
required |
locale
|
str
|
Requested locale when a registry is supplied. |
'en-GB'
|
Returns:
| Type | Description |
|---|---|
list[tuple[Selection, InterpretationEntry | None]]
|
A list of |
list[tuple[Selection, InterpretationEntry | None]]
|
when no dataset covers the selection's symbol. |