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

Function _direction_match_terms

scripts/drift_engine.py:101–130  ·  view source on GitHub ↗
(direction: str)

Source from the content-addressed store, hash-verified

99
100def _direction_match_terms(direction: str) -> List[str]:
101 cleaned = str(direction or "").strip()
102 if not cleaned:
103 return []
104
105 terms = {
106 cleaned.lower(),
107 cleaned.lower().replace("-", " "),
108 cleaned.lower().replace("_", " "),
109 }
110
111 if direction_lexicon and hasattr(direction_lexicon, "resolve_canonical_direction"):
112 try:
113 resolved = direction_lexicon.resolve_canonical_direction(cleaned, include_paper_terms=True)
114 except Exception:
115 resolved = None
116 entry = (resolved or {}).get("entry") or {}
117 for raw_term in (
118 [entry.get("name"), entry.get("name_cn")]
119 + list(entry.get("aliases", []) or [])
120 + list(entry.get("paper_terms", []) or [])
121 ):
122 if raw_term:
123 lowered = str(raw_term).strip().lower()
124 if lowered:
125 terms.add(lowered)
126 terms.add(lowered.replace("-", " "))
127 terms.add(lowered.replace("_", " "))
128
129 return [term for term in terms if term]
130
131
132def _normalize_weight_map(weights: Dict[str, Any]) -> Dict[str, float]:
133 normalized: Dict[str, float] = {}

Callers 3

_extract_anchor_signalFunction · 0.70
_paper_matches_any_topicFunction · 0.70

Calls 1

getMethod · 0.80

Tested by

no test coverage detected