(self, text: str)
| 364 | def _normalize_text(self, text: str) -> str: |
| 365 | normalized = re.sub(r"\s+", " ", str(text or "")).strip() |
| 366 | return normalized[:8000] |
| 367 | |
| 368 | def _cache_key(self, text: str) -> str: |
| 369 | payload = f"{self.descriptor}:{text}" |
| 370 | return hashlib.sha256(payload.encode("utf-8")).hexdigest() |
| 371 | |
| 372 | def _cache_path(self, text: str) -> Path: |
| 373 | return self.cache_dir / f"{self._cache_key(text)}.json" |
| 374 | |
| 375 | def _load_cached(self, text: str) -> Optional[List[float]]: |
| 376 | cache_path = self._cache_path(text) |
| 377 | if not cache_path.exists(): |
| 378 | return None |
| 379 | |
| 380 | try: |
| 381 | data = json.loads(cache_path.read_text(encoding="utf-8")) |
| 382 | except (json.JSONDecodeError, OSError): |
no test coverage detected