Tamil grammar in silicon

Part 2 · How a stem meets its ending, and what is on the chip

Last time I said I'd test whether Tamil noun grammar can run on a chip, with Tolkāppiyam and Naṉṉūl as axioms. TLP1, one byte per sound, is built on the first axiom. Place of articulation sits in the low three bits, so the sound change in மரங்கள் is two masks and an OR: ம் is 54 in hex, க் is 40, and (54 & F8) | (40 & 07) = 50, which is ங்.

From மரம் to மரத்தில்

Now மரத்தில். Naṉṉūl counts eight வேற்றுமை (291), named by their markers (292): the bare name, ஐ, ஆல், கு, இன், அது, கண், and the vocative. Verse 299 gives the உருபு of the fifth case as இல் and இன், though today we'd call இல் the locative, "in". So மரத்தில் is மரம் plus இல், with something in between.

The verses

Axiom three, Naṉṉūl 243:

பதம்முன் விகுதியும் பதமும் உருபும்
புணர்வழி ஒன்றும் பலவும் சாரியை
வருதலும் தவிர்தலும் விகற்பமும் ஆகும்

Naṉṉūl 244:

அன் ஆன் இன் அல் அற்று இற்று அத்து அம்
தம் நம் நும் ஏ அ உ ஐ கு ன
இன்ன பிறவும் பொதுச் சாரியையே

Naṉṉūl 253:

இதற்கு இது சாரியை எனின் அளவு இன்மையின்
விகுதியும் பதமும் உருபும் பகுத்து இடை
நின்ற எழுத்தும் பதமும் இயற்கையும்
ஒன்ற உணர்த்தல் உரவோர் நெறியே

Axiom four, Naṉṉūl 164:

உயிர்வரின் உக்குறள் மெய்விட்டு ஓடும்
யவ்வரின் இய்யாம் முற்றும் அற்று ஒரோ வழி

The something is a சாரியை, a linking increment. Naṉṉūl 243 lets one appear, drop out or be optional, and Naṉṉūl 253 doesn't say which. So I take the right output for a slot to be the whole set of forms the verses allow.

One slot, five licensed forms: மரத்தில், மரத்தின், மரத்திலிருந்து, மரத்தினில், மரத்தினிலிருந்து
One slot, five licensed forms: மரத்தில், மரத்தின், மரத்திலிருந்து, மரத்தினில், மரத்தினிலிருந்து Open full size

What is on the chip

A class table on the chip says that nouns like மரம் get "cut the last byte, add அத்து". The verses cover each step: after ம், அத்து is the சாரியை (Tolkāppiyam உருபியல் 13), and the ம் drops before it (புள்ளிமயங்கியல் 15). மர is 54 00 63 00 (hex) and அத்து, from Naṉṉūl 244, is 00 43 43 02. The vowels run அ இ உ எ ஒ as 00 to 04, and a நெடில் adds 08 (ஊ is 0A).

மரம் reduced to its last three sounds, ர் அ ம், entering a block of 132 logic cells that outputs class C15 and the increment அத்து
மரம் reduced to its last three sounds, ர் அ ம், entering a block of 132 logic cells that outputs class C15 and the increment அத்து Open full size

Seam one: 00 meets 00. Equal vowels, so one drops (Naṉṉūl 252). That is one compare. Result மரத்து.

Seam two: மரத்து meets இல் (01 65). The left ends in 02 (உ) after a consonant and the right starts with a vowel, so the உ drops (Naṉṉūl 164). Three tests. That leaves 54 00 63 00 43 43 01 65, which is மரத்தில்.

Same seam for பசு + இல்: that உ is a முற்றியலுகரம், outside Naṉṉūl 94's list, so Naṉṉūl 164 leaves it and Naṉṉūl 162 adds a glide: பசுவில்.

மரத்தில் as bytes through the two seams: equal vowels merge, then the உ drops
மரத்தில் as bytes through the two seams: equal vowels merge, then the உ drops Open full size

How well it does

114 parameters replace 28 rewrite rules and 1,609 stored suffix spellings; about 80 of them are class values I took from ThamizhiMorph's lexicon, and deriving them from the verses is the next job. Six of the 28 rules only fix spelling after a join, and they have nothing to do when each sound is one byte.

My output contains ThamizhiMorph's form in 99.2% of 1.5 million stem-and-case slots. On a treebank annotated by other people it gets 87.0% of the 740 noun forms I could test (a development score: the first run gave 81%). The dative was weakest; it's corrected, and the next post gives the verse.

Which declension a noun follows

The chip also has to know which declension a noun follows. It needs only the last three sounds, the word's length and its vowel count; the rules were fitted to ThamizhiMorph's lexicon. In software it picks ThamizhiMorph's class for 99.8% of 43,696 nouns. On an FPGA the decision takes 132 logic cells (lookup tables) and no memory. A word arrives one sound at a time, so I added memory for what has come so far: 36 memory bits and 64 more cells, 196 in all. It gives the software's class for all 43,647 nouns it can read. The joining rules above and a whole-form generator work in simulation, not yet connected.

Code and a request

The code is on GitHub: github.com/Ramaseshanr/tamil-grammar-silicon (nouns only, unfinished). If you work on Tamil computation, or think I've misread a verse, tell me.

Part one sets out the first two axioms and the bit operations used here.