MCPcopy Create free account
hub / github.com/OpenRaiser/PaperFlow / resolve_canonical_direction

Function resolve_canonical_direction

config/direction_lexicon.py:550–570  ·  view source on GitHub ↗
(
    value: Any,
    *,
    lexicon: Optional[Dict[str, Any]] = None,
    include_paper_terms: bool = True,
)

Source from the content-addressed store, hash-verified

548
549
550def resolve_canonical_direction(
551 value: Any,
552 *,
553 lexicon: Optional[Dict[str, Any]] = None,
554 include_paper_terms: bool = True,
555) -> Optional[Dict[str, Any]]:
556 normalized_lookup = _normalize_lookup_key(value)
557 if not normalized_lookup:
558 return None
559
560 current_lexicon = lexicon or load_lexicon()
561 for canonical_name, entry in current_lexicon.items():
562 for match_field, raw_term in _iter_match_terms(entry, include_paper_terms=include_paper_terms):
563 if _normalize_lookup_key(raw_term) == normalized_lookup:
564 return {
565 "canonical_name": canonical_name,
566 "match_field": match_field,
567 "matched_text": str(raw_term),
568 "entry": copy.deepcopy(entry),
569 }
570 return None
571
572
573def get_lexicon_keywords() -> Dict[str, List[str]]:

Calls 3

_normalize_lookup_keyFunction · 0.85
load_lexiconFunction · 0.85
_iter_match_termsFunction · 0.85

Tested by

no test coverage detected