(target: Dict[str, float], vector: Dict[str, float], weight: float)
| 305 | |
| 306 | |
| 307 | def add_weighted_vector(target: Dict[str, float], vector: Dict[str, float], weight: float) -> None: |
| 308 | if weight <= 0: |
| 309 | return |
| 310 | for key, value in vector.items(): |
| 311 | target[key] = target.get(key, 0.0) + value * weight |
| 312 | |
| 313 | |
| 314 | def cosine(left: Dict[str, float], right: Dict[str, float]) -> float: |