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

Function cosine

experiments/baselines/knowledge_entity/runner.py:269–274  ·  view source on GitHub ↗
(left: Dict[str, float], right: Dict[str, float])

Source from the content-addressed store, hash-verified

267
268
269def cosine(left: Dict[str, float], right: Dict[str, float]) -> float:
270 if not left or not right:
271 return 0.0
272 if len(left) > len(right):
273 left, right = right, left
274 return sum(value * right.get(key, 0.0) for key, value in left.items())
275
276
277def scaled_similarity(left: Dict[str, float], right: Dict[str, float]) -> float:

Callers 1

scaled_similarityFunction · 0.70

Calls 1

getMethod · 0.80

Tested by

no test coverage detected