Skip to content

Greek Isopsephy

A Greek isopsephy engine that deterministically sums the Milesian/Ionic alphabetic numeral values of a Greek word (units, tens, hundreds, including the archaic signs digamma=6, qoppa=90, sampi=900). Diacritics are stripped and final sigma is normalized to sigma by default; the raw total is stamped over a single structural result symbol.

from fortune_telling_core import Querent, ReadingRequest
from fortune_telling_core.traditions.greek_isopsephy import (
    GREEK_ISOPSEPHY_DECK,
    GREEK_ISOPSEPHY_SPREAD,
    build_engine,
)

request = ReadingRequest(
    deck_id=GREEK_ISOPSEPHY_DECK.id,
    spread_id=GREEK_ISOPSEPHY_SPREAD.id,
    querent=Querent(id="sample", display_name="Sample", attributes={"name": "λόγος"}),
)
reading = build_engine().cast(request)
# reading.summary -> "Isopsephy total 373."

greek_isopsephy

GREEK_ISOPSEPHY_DECK module-attribute

GREEK_ISOPSEPHY_DECK = Deck(
    id="greek_isopsephy.deck.total.v1",
    symbols=(
        Symbol(
            id=GREEK_ISOPSEPHY_RESULT_SYMBOL,
            name="Isopsephy Total",
            attributes={"kind": "raw_total"},
        ),
    ),
)

GREEK_ISOPSEPHY_SPREAD module-attribute

GREEK_ISOPSEPHY_SPREAD = Spread(
    id="greek_isopsephy.spread.name.v1",
    name="Greek Isopsephy Total",
    positions=(
        Position(
            "total",
            "Total",
            "The summed isopsephy value of the name.",
        ),
    ),
)

DiacriticsMode

Bases: StrEnum

How Greek diacritics are handled.

STRIPPED class-attribute instance-attribute

STRIPPED = 'stripped'

Era

Bases: StrEnum

Supported Greek isopsephy tables.

CLASSICAL class-attribute instance-attribute

CLASSICAL = 'classical'

SigmaMode

Bases: StrEnum

How final sigma is handled.

FINAL_TO_SIGMA class-attribute instance-attribute

FINAL_TO_SIGMA = 'final_to_sigma'

DISTINCT class-attribute instance-attribute

DISTINCT = 'distinct'

GreekIsopsephyEngine

GreekIsopsephyEngine(
    *,
    era: Era = Era.CLASSICAL,
    diacritics: DiacriticsMode = DiacriticsMode.STRIPPED,
    sigma_mode: SigmaMode = SigmaMode.FINAL_TO_SIGMA,
)

Bases: AbstractEngine

Greek isopsephy engine.

Source code in src/fortune_telling_core/traditions/greek_isopsephy/engine.py
def __init__(
    self,
    *,
    era: Era = Era.CLASSICAL,
    diacritics: DiacriticsMode = DiacriticsMode.STRIPPED,
    sigma_mode: SigmaMode = SigmaMode.FINAL_TO_SIGMA,
) -> None:
    self.era = era
    self.diacritics = diacritics
    self.sigma_mode = sigma_mode

id class-attribute instance-attribute

id = 'greek_isopsephy.engine'

version class-attribute instance-attribute

version = '0.1.0'

era instance-attribute

era = era

diacritics instance-attribute

diacritics = diacritics

sigma_mode instance-attribute

sigma_mode = sigma_mode

deck

deck(request: ReadingRequest) -> Deck

Return the Greek isopsephy deck.

Source code in src/fortune_telling_core/traditions/greek_isopsephy/engine.py
def deck(self, request: ReadingRequest) -> Deck:
    """Return the Greek isopsephy deck."""

    if request.deck_id != GREEK_ISOPSEPHY_DECK.id:
        raise ValidationError(f"unsupported Greek isopsephy deck: {request.deck_id}")
    return GREEK_ISOPSEPHY_DECK

spread

spread(request: ReadingRequest) -> Spread

Return the Greek isopsephy spread.

Source code in src/fortune_telling_core/traditions/greek_isopsephy/engine.py
def spread(self, request: ReadingRequest) -> Spread:
    """Return the Greek isopsephy spread."""

    if request.spread_id != GREEK_ISOPSEPHY_SPREAD.id:
        raise ValidationError(f"unsupported Greek isopsephy spread: {request.spread_id}")
    return GREEK_ISOPSEPHY_SPREAD

draw

draw(request: ReadingRequest, rng: Rng) -> Draw

Compute the isopsephy total as a deterministic draw.

Source code in src/fortune_telling_core/traditions/greek_isopsephy/engine.py
def draw(self, request: ReadingRequest, rng: Rng) -> Draw:
    """Compute the isopsephy total as a deterministic draw."""

    del rng
    fields = collect_values(request)
    name = require_string(fields, "name")
    era = _parse_era(fields.get("era"), self.era)
    diacritics = _parse_diacritics(fields.get("diacritics"), self.diacritics)
    sigma_mode = _parse_sigma_mode(fields.get("sigma_mode"), self.sigma_mode)

    units = greek_isopsephy.values(
        name,
        era=era,
        diacritics=diacritics,
        sigma_mode=sigma_mode,
    )
    if not units:
        raise ValidationError("name must contain at least one Greek letter")
    total = greek_isopsephy.total(units)

    selection = Selection(
        "total",
        GREEK_ISOPSEPHY_RESULT_SYMBOL,
        {
            "value": str(total),
            "total": str(total),
            "value_system": greek_isopsephy.ID,
            "value_system_version": greek_isopsephy.VERSION,
            "era": era.value,
            "diacritics": diacritics.value,
            "sigma_mode": sigma_mode.value,
            "normalized_name": "".join(unit.char for unit in units),
            "values": format_value_trace(units),
        },
    )
    return Draw(GREEK_ISOPSEPHY_DECK.id, GREEK_ISOPSEPHY_SPREAD.id, (selection,))

cast

cast(request: ReadingRequest) -> Reading

Compute a Greek isopsephy reading without a caller RNG.

Source code in src/fortune_telling_core/traditions/greek_isopsephy/engine.py
def cast(self, request: ReadingRequest) -> Reading:
    """Compute a Greek isopsephy reading without a caller RNG."""

    draw = self.draw(request, _NULL_RNG)
    return self._interpret(request, draw, rng=None)

build_engine

build_engine(
    *,
    era: Era = Era.CLASSICAL,
    diacritics: DiacriticsMode = DiacriticsMode.STRIPPED,
    sigma_mode: SigmaMode = SigmaMode.FINAL_TO_SIGMA,
) -> GreekIsopsephyEngine

Create a Greek isopsephy engine.

Source code in src/fortune_telling_core/traditions/greek_isopsephy/engine.py
def build_engine(
    *,
    era: Era = Era.CLASSICAL,
    diacritics: DiacriticsMode = DiacriticsMode.STRIPPED,
    sigma_mode: SigmaMode = SigmaMode.FINAL_TO_SIGMA,
) -> GreekIsopsephyEngine:
    """Create a Greek isopsephy engine."""

    return GreekIsopsephyEngine(era=era, diacritics=diacritics, sigma_mode=sigma_mode)