(text: str)
| 95 | |
| 96 | |
| 97 | def language_hint_for_text(text: str) -> str: |
| 98 | cjk_chars = len(re.findall(r"[\u3400-\u9fff]", text or "")) |
| 99 | latin_chars = len(re.findall(r"[A-Za-z]", text or "")) |
| 100 | total = cjk_chars + latin_chars |
| 101 | if total == 0: |
| 102 | return "unknown" |
| 103 | if cjk_chars / total >= 0.6: |
| 104 | return "zh" |
| 105 | if latin_chars / total >= 0.6: |
| 106 | return "en" |
| 107 | return "mixed" |
| 108 | |
| 109 | |
| 110 | def new_record(kind: str, title: str, page_number: int, seen: dict[str, int]) -> dict[str, Any]: |