(self, path: Path)
| 208 | return (complexity, best, probs[best]) |
| 209 | |
| 210 | def save(self, path: Path) -> None: |
| 211 | data = { |
| 212 | "avg_weights": { |
| 213 | t: {k: v for k, v in w.items() if abs(v) > 1e-6} |
| 214 | for t, w in self._avg_weights.items() |
| 215 | }, |
| 216 | "weights": { |
| 217 | t: {k: v for k, v in w.items() if abs(v) > 1e-6} |
| 218 | for t, w in self._weights.items() |
| 219 | }, |
| 220 | "update_count": self._update_count, |
| 221 | "use_ngrams": self._use_ngrams, |
| 222 | } |
| 223 | path.parent.mkdir(parents=True, exist_ok=True) |
| 224 | path.write_text(json.dumps(data)) |
| 225 | |
| 226 | @classmethod |
| 227 | def _collapse_loaded_weights( |
no outgoing calls
no test coverage detected