MCPcopy Create free account
hub / github.com/917Dhj/DeepPaperNote / language_hint_for_text

Function language_hint_for_text

scripts/extract_source_text.py:97–107  ·  view source on GitHub ↗
(text: str)

Source from the content-addressed store, hash-verified

95
96
97def 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
110def new_record(kind: str, title: str, page_number: int, seen: dict[str, int]) -> dict[str, Any]:

Callers 1

build_manifestFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected