(
value: Any,
*,
lexicon: Optional[Dict[str, Any]] = None,
include_paper_terms: bool = True,
)
| 548 | |
| 549 | |
| 550 | def 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 | |
| 573 | def get_lexicon_keywords() -> Dict[str, List[str]]: |
no test coverage detected