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

Function normalize_vector

experiments/baselines/scholar_inbox/runner.py:217–221  ·  view source on GitHub ↗
(vector: Dict[str, float])

Source from the content-addressed store, hash-verified

215
216
217def normalize_vector(vector: Dict[str, float]) -> Dict[str, float]:
218 norm = math.sqrt(sum(value * value for value in vector.values()))
219 if norm <= 0:
220 return {}
221 return {key: value / norm for key, value in vector.items() if value}
222
223
224def add_weighted_vector(target: Dict[str, float], vector: Dict[str, float], weight: float) -> None:

Callers 3

vectorize_textFunction · 0.70
positive_centroidMethod · 0.70
negative_centroidMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected