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 an abbreviation to its canonical NCM node name.

Falls back to the original string if no mapping exists (it may already be a full node name).

Return type:

str

Parameters:

abbrev (str)

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.2, 'DAT_ACTIVITY': 0.2}
Return type:

Dict[str, float]

Parameters:

delta_str (str)

ncm_delta_parser.get_emotion_delta(emotion_name)[source]

Get the parsed NCM delta vector for a named emotion.

Returns an empty dict if the emotion is not found.

Return type:

Dict[str, float]

Parameters:

emotion_name (str)

ncm_delta_parser.get_all_emotions()[source]

Return the full emotion index (cached).

Return type:

Dict[str, Dict[str, Any]]

ncm_delta_parser.scan_text_for_triggers(text, trigger_lexicon=None)[source]

Scan text for emotional trigger words and return matched deltas.

Parameters:
  • text (str) – The text to scan (user message or bot response).

  • trigger_lexicon (Optional[List[str]]) – Optional explicit list of trigger words. If None, uses all emotion names from the recursion index.

Return type:

List[Tuple[str, Dict[str, float]]]

ncm_delta_parser.combine_deltas(delta_list, scale=1.0)[source]

Combine multiple delta vectors into one, optionally scaled.

When multiple emotions fire simultaneously, their deltas stack but are scaled down to prevent runaway:

combined = scale * Σ(delta_i) / sqrt(N)

Return type:

Dict[str, float]

Parameters: