Universal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.
fix(content-quality): flag partial signal coverage for CJK text
Agrici Daniel9cf236b832cc
diff --git a/scripts/content_quality.py b/scripts/content_quality.pyindex 8725fd6..3c6b088 100644--- a/scripts/content_quality.py+++ b/scripts/content_quality.py@@ -31,7 +31,14 @@ Output (JSON when ``--json`` is set)::"flags": ["filler", "ai-patterns", "low-density", ...],"matches": {"filler": [...], "ai_patterns": [...]},"tokens": int,- "unique_tokens": int+ "unique_tokens": int,+ "coverage": present only for CJK-dominant text, e.g.+ {"script": "cjk", "entity_density": "not_computed",+ "phrase_lists": "english_only"}: the+ filler/AI-pattern phrase lists and the+ capitalisation-based entity heuristic are+ English-only, so a CJK score is not directly+ comparable to a Latin-script one.}Attribution@@ -158,6 +165,27 @@ _ENTITY_RE = re.compile(r"\b(?:[A-Z][a-z]+(?:\s+[A-Z][a-z]+)+)\b")# on _NUMBER_RE alone and skews low. Tokenisation (above) is the load-bearing# fix; CJK named-entity detection needs a real model, not a regex.+# Same character classes as the CJK branches of _TOKEN_RE, used only to guess+# whether a text is CJK-dominant so we can flag which signals below are not+# meaningfully computed for it. Not a language detector.+_CJK_CHAR_RE = re.compile(+ r"[가-힣ぁ-ゖァ-ヺー㐀-䶿一-鿿]"+)+_LATIN_CHAR_RE = re.compile(r"[A-Za-z]")+++def _detect_script(text: str) -> str | None:+ """Return "cjk" when CJK/Hangul/kana characters dominate ``text``, else None.++ ``None`` covers Latin-script and any other text; the coverage note is+ only added when the score's known-unreliable-for-CJK signals apply.+ """+ cjk_chars = len(_CJK_CHAR_RE.findall(text))+ if cjk_chars == 0:+ return None+ latin_chars = len(_LATIN_CHAR_RE.findall(text))+ return "cjk" if cjk_chars >= latin_chars else None+def _count_phrase_hits(text: str, patterns: Iterable[str]) -> list[str]:"""Return the patterns that appear at least once in ``text`` (case-insensitive)."""@@ -237,7 +265,7 @@ def analyse(text: str) -> dict:+ min(100, n_tokens / 10.0) * 0.10 # length bonus capped at 1000 tokens)- return {+ result = {"filler_score": filler_score,"ai_pattern_score": ai_pattern_score,"information_density": round(information_density, 3),@@ -249,6 +277,22 @@ def analyse(text: str) -> dict:"unique_tokens": unique,}+ # The filler/AI-pattern phrase lists and the capitalisation-based entity+ # heuristic are English-only; they are silently near-zero for CJK text+ # rather than reporting "no filler found". Flag that explicitly so a CJK+ # score is never read as comparable to a Latin-script one. Latin/other+ # output is unchanged: no "coverage" key is added when every signal was+ # actually computed.+ script = _detect_script(text)+ if script == "cjk":+ result["coverage"] = {+ "script": "cjk",+ "entity_density": "not_computed",+ "phrase_lists": "english_only",+ }++ return result+def main() -> int:parser = argparse.ArgumentParser(@@ -294,6 +338,12 @@ def main() -> int:if result["matches"]["ai_patterns"]:print(f" AI-pattern hits: {', '.join(result['matches']['ai_patterns'][:5])}"f"{' …' if len(result['matches']['ai_patterns']) > 5 else ''}")+ if result.get("coverage"):+ print(+ " Note: CJK text detected, entity-density and phrase-list "+ "signals are English-only heuristics here, so this score is "+ "not directly comparable to a Latin-script page."+ )return 0 if result["overall_quality"] >= args.threshold else 1diff --git a/tests/test_content_quality.py b/tests/test_content_quality.pyindex 4324df4..d4a7b07 100644--- a/tests/test_content_quality.py+++ b/tests/test_content_quality.py@@ -157,6 +157,58 @@ def test_content_quality_latin_scoring_unchanged_by_cjk_support() -> None:), result+def test_content_quality_english_output_keys_and_values_unchanged() -> None:+ """English-language output must be byte-for-byte the same shape as before+ the CJK coverage note: no ``coverage`` key, same keys, same values."""+ text = (+ "In today's fast-paced world, when it comes to SEO, "+ "it's important to note that delving into the ever-evolving "+ "landscape requires us to leverage the power of cutting-edge "+ "strategies to unlock the potential of organic traffic."+ ) * 5+ result = content_quality.analyse(text)+ assert set(result.keys()) == {+ "filler_score",+ "ai_pattern_score",+ "information_density",+ "repetition_score",+ "overall_quality",+ "flags",+ "matches",+ "tokens",+ "unique_tokens",+ }+ assert "coverage" not in result+++def test_content_quality_cjk_output_carries_coverage_object() -> None:+ """A CJK score must be flagged as partial coverage, not silently compared+ to an English score as if every signal were computed the same way."""+ text = (+ "사주팔자는 태어난 연월일시를 천간과 지지로 옮긴 여덟 글자입니다. "+ "절기를 기준으로 월주를 정하고, 진태양시로 시주를 보정합니다. "+ "오행의 균형과 십신의 배치를 함께 살펴 전체 흐름을 읽습니다."+ )+ result = content_quality.analyse(text)+ assert result["coverage"] == {+ "script": "cjk",+ "entity_density": "not_computed",+ "phrase_lists": "english_only",+ }+++def test_content_quality_cjk_human_output_notes_partial_coverage() -> None:+ """The CLI's human-readable summary must call out partial CJK coverage."""+ script = Path(__file__).resolve().parents[1] / "scripts" / "content_quality.py"+ text = "사주팔자는 태어난 연월일시를 천간과 지지로 옮긴 여덟 글자입니다. " * 5+ result = subprocess.run(+ [sys.executable, str(script)],+ input=text, capture_output=True, text=True,+ )+ assert result.returncode in (0, 1)+ assert "not directly comparable" in result.stdout++# ---------------------------------------------------------------------------# content_humanize# ---------------------------------------------------------------------------