Files
2026-10-15 16:30:44 +08:00

34 lines
1.1 KiB
Python

"""Report text that is still English in the localized page (gap finder)."""
import re, sys
from bs4 import BeautifulSoup, NavigableString, Comment
SRC = r"C:/Users/yvmou/Downloads/limboai-readthedocs-io-en-stable/limboai-stable/index.zh.html"
SKIP = {"script", "style", "pre", "code", "kbd", "samp", "var", "tt"}
soup = BeautifulSoup(open(SRC, encoding="utf-8").read(), "lxml")
rows = []
for node in soup.find_all(string=True):
if isinstance(node, Comment):
continue
t = str(node).strip()
if not re.search(r"[A-Za-z]", t):
continue
if any(getattr(p, "name", None) in SKIP for p in node.parents):
continue
words = re.findall(r"[A-Za-z][A-Za-z'\-]+", t)
long_words = [w for w in words if len(w) > 2 and not w[0].isupper()]
if len(words) >= 4 or len(long_words) >= 2:
parents = "/".join(p.name for p in list(node.parents)[:3])
rows.append((parents, t))
print("leftover english-ish text nodes:", len(rows))
seen = set()
for p, t in rows:
k = t[:60]
if k in seen:
continue
seen.add(k)
print(" [%s] %s" % (p, t[:150]))
if len(seen) > 40:
break