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

Function normalize_vector

experiments/baselines/nl_profile/runner.py:193–197  ·  view source on GitHub ↗
(vector: Dict[str, float])

Source from the content-addressed store, hash-verified

191
192
193def normalize_vector(vector: Dict[str, float]) -> Dict[str, float]:
194 norm = math.sqrt(sum(value * value for value in vector.values()))
195 if norm <= 0:
196 return {}
197 return {key: value / norm for key, value in vector.items() if value}
198
199
200def cosine(left: Dict[str, float], right: Dict[str, float]) -> float:

Callers 1

vectorize_textFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected