(target: Dict[str, float], vector: Dict[str, float], weight: float)
| 222 | |
| 223 | |
| 224 | def add_weighted_vector(target: Dict[str, float], vector: Dict[str, float], weight: float) -> None: |
| 225 | if weight <= 0: |
| 226 | return |
| 227 | for key, value in vector.items(): |
| 228 | target[key] = target.get(key, 0.0) + value * weight |
| 229 | |
| 230 | |
| 231 | def cosine(left: Dict[str, float], right: Dict[str, float]) -> float: |