Skip to content

chore: migrate L1 language validator to lingua detector#83

Merged
ChBrain merged 16 commits into
mainfrom
chore/migrate-L1-to-tests
May 6, 2026
Merged

chore: migrate L1 language validator to lingua detector#83
ChBrain merged 16 commits into
mainfrom
chore/migrate-L1-to-tests

Conversation

@ChBrain

@ChBrain ChBrain commented May 6, 2026

Copy link
Copy Markdown
Owner

What

Replaces the old regex-based German bleed detector with lingua-language-detector, a span-based multilingual detection library.

Why

The old approach used hardcoded German verb/phrase regexes - brittle, easy to evade, and unable to detect non-German violations. lingua detects language spans across the full prose, flags long non-English runs as violations, and ignores short spans (Eigennamen).

How

  • tests/validate_language.py rewritten: detect_multiple_languages_of returns spans for both languages in mixed text. Spans ≥ 15 words in a non-allowed language = violation. Short spans = proper nouns, ignored.
  • Only prose sections checked (## Shown, ## Offers, ## Withheld). ## Holds skipped by design (carries km/exit lists dense with German place names).
  • ALLOWED_LANGUAGES env var (default: english). Override: ALLOWED_LANGUAGES=english,german python tests/validate_language.py.
  • tests/requirements.txt added (lingua-language-detector>=2.2.0).
  • tests/language_exceptions.txt added for genuine Eigenname false positives (currently only autobahn).
  • CI: pip install -r tests/requirements.txt added to L1 job in validate.yml and validate-version-bump.yml.
  • ARCHITECTURE.md: language policy section added (English + Eigennamen only; fix content if validator fires, do not adjust threshold).

Content fixes (5 files)

Validator at threshold 15 found 5 files with real violations or architectural problems:

  • roads/a111/place_a111_tunnel_tegel.md - ## Shown opened with tunnel identifiers and metre measurements (not driver experience). Rewritten to open with the cutting, ceiling, acoustics.
  • roads/a20/place_a20_33_friedland.md - ## Withheld had dense Slavic/Germanic proper noun cluster triggering Polish false positive. Rewritten with better sentence structure; same history, proper nouns spread.
  • roads/a24/place_a24_03_kreuz_hamburg_ost.md - ## Shown described road network topology. Rewritten as driver approach. ## Withheld Bismarck/Sachsenwald paragraph rewritten to spread proper nouns.
  • roads/a40/place_a40_23_essen_zentrum.md - Navigation bullet list in ## Shown (architecture violation). Moved to ## Holds.
  • roads/a40/place_a40_24_essen_huttrop.md - Same navigation violation. Fixed.

Validation

python tests/validate_language.pyOK: 343 file(s) passed language policy (english)

ChBrain added 16 commits May 6, 2026 09:24
…german-bleed, L2-structure, L3-state, L4-roads, L5-km-math)
…Eigennamen-only exception, detect German subtitles
@ChBrain
ChBrain merged commit 24bfeba into main May 6, 2026
10 checks passed
@ChBrain
ChBrain deleted the chore/migrate-L1-to-tests branch May 6, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant