Skip to content

Phase 2a-2c: வெண்பா.ஆய்வு — venba validator with தளை and ஈற்றுச்சீர் checks - #15

Open
srix wants to merge 6 commits into
masterfrom
phase2/venba-validator
Open

srix wants to merge 6 commits into
masterfrom
phase2/venba-validator

Conversation

@srix

@srix srix commented Sep 20, 2026

Copy link
Copy Markdown
Owner

Roadmap Phase 2a-2c from specs/2026-09-20-revival-and-roadmap.md. First venba verdict: until now சீர்கொடு only labelled feet.

New

  • pytamil/தமிழ்/தளை.py: the eight தளைகள் as tables (தளை_கொடு, வெண்டளையா, சீர்வகை, முதலசை). No ANTLR.
  • வெண்பா.ஆய்வு(பாடல்) -> ஆய்வுமுடிவு with வகை, per-foot சீர்விவரம்(பதம், வாய்பாடு, அசைகள்), per-junction தளைவிவரம், and a list of பிழை(விதி, அடி, சீர், விவரம்). Rules: பாகுபாட்டுப்பிழை, அடி_எண்ணிக்கை, அடி_சீர்_எண்ணிக்கை, ஈற்றடி_சீர்_எண்ணிக்கை, ஈற்றுச்சீர்_பிழை, கனிச்சீர்_தடை, வெண்டளை_பிழை (junctions across lines included). Never raises.
  • மரம்காட்டு.py: tree pretty-printing moved out of வெண்பா.py.

Changed

  • வெண்பா.g4 now parses structure only (அடி* ஈற்றடி EOF, any number of feet per line, கனி admitted so it can be reported). All venba rules live in Python, so an invalid poem still parses and every violation is listed with line/foot numbers. Venba type is decided from the line count, which also makes சிந்தியல் reachable.
  • சீர்கொடு unchanged in behaviour; it is now a wrapper over ஆய்வு.

Finding worth reading: the grammar needs metrical spacing (by சீர்), not word spacing. Kural 467's எண்ணுவம் என்பது இழுக்கு genuinely has விளமுன் நிரை at the last junction; எண்ணுவ மென்பதி ழுக்கு is all வெண்டளை. Recorded in the spec; it means the corpus run (2e) needs a சீர்-spaced source or the Phase 3 sandhi work.

Suite: 183 passed, 9 xfailed. Merge with a merge commit.

🤖 Generated with Claude Code

srix and others added 6 commits September 20, 2026 16:57
…ய்வி

இதுவரை வெண்பா.சீர்கொடு சீர் வாய்பாடுகளை மட்டும் தந்தது; வெண்பாவா இல்லையா என்று
சொல்லும் வழி இல்லை. இப்போது:

- தளை.py (புதிது): மா/விளம்/காய்/கனி + நேர்/நிரை -> எட்டு தளைகள் அட்டவணை;
  தளை_கொடு(முன்சீர், பின்சீர்), வெண்டளையா(), சீர்வகை(), முதலசை(). ANTLR சாராது.
- வெண்பா.g4: அமைப்பை மட்டும் பாகுபடுத்தும் (அடி* ஈற்றடி EOF; சீர்கள் எத்தனையும்;
  கனிச்சீரும் ஏற்கும்) — விதிகள் Python-இல். விதி மீறிய பாடலும் பாகுபடும், ஒவ்வொரு
  மீறலும் தனித்தனியே அறிவிக்கப்படும். வகை (குறள்/சிந்தியல்/நேரிசை/பஃறொடை/கலி) அடி
  எண்ணிக்கையால்; இதனால் முன்பு அடைய முடியாதிருந்த சிந்தியல் வெண்பாவும் வந்தது.
- வெண்பா.ஆய்வு(பாடல்) -> ஆய்வுமுடிவு(வகை, அடிகள்[சீர்விவரம்], தளைகள்[தளைவிவரம்],
  பிழைகள்[பிழை], சரியா). விதிகள்: பாகுபாட்டுப்பிழை, அடி_எண்ணிக்கை, அடி_சீர்_எண்ணிக்கை,
  ஈற்றடி_சீர்_எண்ணிக்கை, ஈற்றுச்சீர்_பிழை, கனிச்சீர்_தடை, வெண்டளை_பிழை (அடி இணைப்பும்
  உட்பட). சீர்கொடு() பழைய இடைமுகமாக அப்படியே.
- மரம்காட்டு.py (புதிது): மரத்தை உரையாகக் காட்டும் nltk உதவிகள் வெண்பா.py-இலிருந்து
  இங்கு; வெண்பா.py பகுப்பாய்வு மட்டும்.

கண்டுபிடிப்பு: உள்ளீடு சீர்ப் பிரிப்புப்படி இடைவெளி இட்ட யாப்பு வடிவமாக இருக்க வேண்டும்.
குறள் 467 சொற்பிரிப்பில் ("எண்ணுவம் என்பது இழுக்கு") விளமுன் நிரை என்ற தளைப் பிழை
காட்டும்; யாப்பு வடிவில் ("எண்ணுவ மென்பதி ழுக்கு") எல்லாம் வெண்டளை. specs/-இல் குறித்தது;
2e corpus run-க்கு இது முக்கியம்.

சோதனைகள்: test_தளை.py (48), test_வெண்பா_ஆய்வு.py (14): குறள் 467, நளவெண்பா 1 சரி;
ஒவ்வொரு விதிக்கும் ஒரு மீறல்; ஆசிரியப்பாவை வெண்பாவாகக் கொடுத்தல்; குப்பை உள்ளீடு.
pytest: 183 passed, 9 xfailed.

Roadmap Phase 2a-2c (specs/2026-09-20-revival-and-roadmap.md).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
திருக்குறள் 1330-இல் 87 குறள்கள் ஒரு நாலசைச்சீர் (எ.கா. குறள் 13 'வியனுலகத்து' =
கருவிளந்தண்பூ) காரணமாக முழுதும் பாகுபடாமல் போயின. கனிச்சீர் போலவே நாலசையையும்
வெண்பா.g4 அமைப்பில் ஏற்று, ஆய்வு() விதிமீறலாக அறிவிக்கிறது. இப்போது 1321/1330
முழுதும் பாகுபடுகின்றன.

தளை.py: நாலசைச்சீர்களுக்கு (...பூ / ...நிழல்) முதலசை, வகை. அனுமானம் — ஈற்றசை நேர்
(...பூ) காய் போலவும், ஈற்றசை நிரை (...நிழல்) கனி போலவும் தளை காணப்படும் — குறிப்பில்
வெளிப்படையாக உள்ளது; இலக்கண ஆய்வுக்குப் பின் மாற்றலாம்.

சொற்பிரிப்புத் திருக்குறளில் baseline: 971/1330 வெண்பாவாக ஏற்கப்படுகின்றன;
வெண்டளை_பிழை 324 (கலித்தளை 188), நாலசைச்சீர்_தடை 86, கனிச்சீர்_தடை 35.

pytest: 189 passed, 9 xfailed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…ருவி

python -m pytamil.திருக்குறள் வெண்பா --வெளியீடு குறள்-வெண்பா.csv [--எண்கள் 1-100,467]

- குறள் உரை Open-Tamil-இன் kural தொகுப்பிலிருந்து (CSV உள்ளீடு தேவையில்லை).
- குறளுக்கு ஒரு வரி: எண், பால், அதிகாரம், குறள், வகை, சரியா, சீர்கள், தளைகள், பிழைகள்.
- தொகுப்பு: ஏற்கப்பட்டவை %, விதிவாரி, தளைவாரி, வகைவாரி எண்ணிக்கைகள்.
- பழைய மாத்திரை CSV மாற்றம் 'மாத்திரை' துணைக்கட்டளையாக அப்படியே.

முதல் ஓட்டம் (சொற்பிரிப்பு உரை): 971/1330 (73.0%) வெண்பாவாக ஏற்பு; வெண்டளை_பிழை 324
(கலித்தளை 188), நாலசைச்சீர்_தடை 86, கனிச்சீர்_தடை 35; 8 குறள்கள் + 16 பகுதி — kural
தொகுப்பின் உரைச் சிதைவு (U+0BA7 போன்ற ஒதுக்கப்படாத எழுத்துகள், துண்டித்த சொற்கள்).
விவரம் specs/ Phase 2e-இல்.

சோதனைகள்: test_திருக்குறள்.py (6). pytest: 195 passed, 9 xfailed.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
pylint reported 6,408 messages, 6,058 of them under codegen/. Those files are
generated by ANTLR (codegen.sh) and are never hand-edited, so linting them has
no value. That leaves 350 worth acting on. Before touching those, this records
in the config the decisions the project has already made on purpose.

- ignore-paths: skip codegen/ entirely.
- C0103 (invalid-name) and W2402 (non-ascii-file-name): Tamil identifiers and
  Tamil module file names are the design of this project, not an accident.
  They join C2401/C2403, which were already disabled.
- no-docstring-rgx=^(_|test_): no docstring required of private helpers or of
  tests, whose names already say what they check.
- generated-members=ruleNames,RULE_*: ANTLR Parser subclasses define these as
  class attributes, but பாகுபடுத்தி annotates only the base antlr4.Parser, so
  pylint reports a false E1101 at every use.
- min-public-methods=0: சான்று, விவரம் and புணர்ச்சிவிதி are value objects.

The file-level `# pylint: disable=invalid-name` in மாத்திரை.py is now redundant.
It only ever covered what came after it, so the module, class and attribute
names above it still warned; the next commit removes it.

pytest: 195 passed, 9 xfailed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Works through the 350 messages left after the previous commit's config. Most
were style (docstrings, line length, dead imports, tab indentation), but three
places turned out to be genuinely broken.

Real bugs:

- திருக்குறள்.py: குறள்_மாத்திரைவரிசைகள்_கொடு() calls re.sub(), but re was never
  imported, so that path raised NameError every time it ran. It works now. The
  same file opened two CSVs with no encoding, which is unsafe for Tamil text;
  both now use utf8.

- இலக்கணம்.py could not be imported at all: wrong package path
  (`from தமிழ் import ...`), and எழுத்தாக்கு / உயிர்மெய்_ஆக்கு / உயிர்மெய்_பிரி were
  called unqualified, the last of them commented out in எழுத்து.py. It imports
  now, and both of its rules work: கல் + அது -> கல்லது, மரம் + அது -> மரமது. Its
  five unwritten functions raise NotImplementedError instead of quietly
  returning None.

- மாத்திரை.py: enterகுற்றியலிகரம்_தனிமொழி() hardcoded the letters மி and யா rather
  than deriving them; the computed உயிர்மெய் sat unused, which is what the
  unused-variable warning was pointing at. Now derived from the input:
  கேண்மியா -> மி, நாடியாது -> டி. Both tests still hold.

Also in புணர்ச்சி.py: filter calls were built as strings and run through eval().
They now go through an explicit name -> function table matching the ebnf's
filtername rule. Unreachable code after a return, referring to an undefined
`ast`, is gone.

Refactors (behaviour unchanged, covered by the suite):

- விதிக்கோப்பு.py (new): the YAML rule-file walker was duplicated verbatim in
  மாத்திரை.py and புணர்ச்சி.py (R0801); it now lives in one place.
- வெண்பா.ஆய்வு() split into _அடி_பிழைகள் and _தளைகள்_சோதி.
- மாத்திரை.printtree / printtree_tofile delegate to மரம்காட்டு.py.
- எழுத்து.py exposes எழுத்துக்கள் publicly, so புணர்ச்சி no longer reaches into
  _எழுத்துக்கள்; உயிர்மெய்_பிரி restored.
- setup.py: distutils -> setuptools (distutils is gone in 3.12), with open().
- Tests: tabs to spaces, dead imports dropped, module docstrings added. No test
  data and no assertion changed.

Comments and docstrings follow the convention already in the codebase: Tamil
for the language itself (எழுத்து, சீர், தளை, மாத்திரை, புணர்ச்சி), English for
programming mechanics (parser, tree, listener, filter, config).

Lint, run where the dependencies are importable:
  PYTHONPATH=$(.venv/bin/python -c 'import site;print(site.getsitepackages()[0])') \
    pylint pytamil pytamil/tests/*.py setup.py     -> 10.00/10

pytest: 195 passed, 9 xfailed. codegen/ untouched.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Neither module is about Tamil. One wraps the ANTLR InputStream -> Lexer ->
CommonTokenStream -> Parser chain; the other draws a parse tree with nltk.
Naming them, and everything inside them, in Tamil was a forced translation of
programming concepts that have no classical Tamil word, and it obscured what
they do. (The branch that first added the helper was called parser-helper.)

  பாகுபடுத்தி.py    -> parsehelper.py
    மரம்_கொடு(...)          -> parse(...)
    பாகுபாடு                -> ParseResult    (மரம்/பிழைகள்/சரியா -> tree/errors/ok)
    பாகுபாட்டுப்பிழை         -> ParseError     (வரி/நெடுக்கை/செய்தி/நிலை ->
                                              line/column/message/stage)
    பாகுபாட்டுவிதிவிலக்கு     -> ParseFailed
    பிழைசேகரிப்பான்          -> ErrorCollector
    தொடக்கவிதி/உரை/கண்டிப்பு -> start_rule/text/strict

  மரம்காட்டு.py     -> treetext.py
    உரைமரம்                 -> as_text
    உரைமரம்_சேமி            -> save_text

Also renames புணர்ச்சி.py's module-level `_பாகுபடுத்தி` (a TatSu parser object)
to `_parser`, and test_பாகுபடுத்தி.py to test_parsehelper.py.

The grammar names passed in stay Tamil, because those are the language: the
call reads parsehelper.parse(வெண்பாLexer, வெண்பாParser, 'வெண்பா', பாடல்).

One deliberate exception: the string 'பாகுபாட்டுப்பிழை' stays as it is. It is a
விதி label in வெண்பா.ஆய்வு's error list, sitting beside அடி_எண்ணிக்கை and
ஈற்றுச்சீர்_பிழை, and it is written into the திருக்குறள் CSV. It is data, not a
code name.

specs/2026-09-20-revival-and-roadmap.md updated to match, since it documents
this API for the phases still to come.

pytest: 195 passed, 9 xfailed. pylint: 10.00/10. No behaviour change.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
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