ncm_delta_parser
NCM Delta Parser: resolves compact delta strings to full NCM vectors.
- Parses the shorthand delta notation from reality_marble_recursion_index.yaml:
“KOR+0.4 D1-0.3 OXT-0.2 5HT1A-0.2 ENT1↑ ACC↑ SERT.reversed”
- Into a proper chemical vector dict:
{“KAPPA_OPIOID_KOR”: 0.4, “DOPAMINE_D1”: -0.3, …}
- ncm_delta_parser.resolve_node_name(abbrev)[source]
Resolve a compact abbreviation to its canonical NCM node name.
Looks the abbreviation up in the module-level
ABBREV_TO_NODEtable, which maps shorthand tokens from the recursion index (for example"KOR"or"5HT1A") to full neurochemical-model node names such as"KAPPA_OPIOID_KOR". If there is no mapping the input is returned unchanged, on the assumption it is already a full node name. This is a pure dictionary lookup with no side effects.Called by
parse_delta_stringin this module for every parsed token, and byflavor_engine.py(via a guarded import) when expanding flavor abbreviations.
- ncm_delta_parser.parse_delta_string(delta_str)[source]
Parse a compact NCM delta string into a resolved chemical vector.
Examples:
>>> parse_delta_string("KOR+0.4 D1-0.3 OXT-0.2 ENT1↑ ACC↑") {'KAPPA_OPIOID_KOR': 0.4, 'DOPAMINE_D1': -0.3, 'OXYTOCIN_NEUROMIRROR': -0.2, 'ENT1_ACTIVITY': 0.15, 'ACC_SAL': 0.15} >>> parse_delta_string("SERT.reversed DAT.reversed") {'SERT_ACTIVITY': -0.35, 'SEROTONERGIC_WARMTH': 0.3, 'DAT_ACTIVITY': -0.35, 'DOPAMINERGIC_CRAVE': 0.35}
A reversed transporter applies
_REVERSAL_MAGNITUDE(clearance disrupted) and, for transporters in_REVERSAL_NT_BOOST, also boosts the parent neurotransmitter to model the resulting synaptic flood.
- ncm_delta_parser.get_emotion_delta(emotion_name)[source]
Return the parsed NCM delta vector for a named emotion.
Normalizes
emotion_name(uppercase, spaces to underscores) and looks it up in the cached emotion index from_load_emotion_index, returning a copy of that emotion’s resolveddelta_vectorso callers cannot mutate the shared cache. An unknown emotion yields an empty dict rather than raising.Called by
ncm_semantic_triggers.pyafter semantic matching, to turn each top-scoring emotion name into a concrete chemical delta.
- ncm_delta_parser.get_all_emotions()[source]
Return the full emotion index, loading and caching it on first use.
Thin public accessor that delegates to
_load_emotion_indexand exposes the complete mapping of emotion name to its parsed record (id, cart, affect, raw and parsed deltas, and optional narrative fields). The returned dict is the live cached object, so callers should treat it as read-only.Called by
limbic_system/engine.py,ncm_semantic_triggers.py, and the trigger-pregeneration scripts underscripts/to enumerate every known emotion and its delta vector.
- ncm_delta_parser.scan_text_for_triggers(text, trigger_lexicon=None)[source]
Scan text for emotional trigger words and return matched deltas.