Module:User:Kritixilithos

-- tamil noun declension, work in progress -- following https://archive.org/details/progressivegramm00ardeiala --  for sandhi rules -- and https://www.sai.uni-heidelberg.de/tamil/pdf/modgram.pdf --  for case declension

--க் ங் ச் ஞ் ட் ண் த் ந் ப் ம் ய் ர் ல் வ் ழ் ள் ற் ன் --k G c C T N t M p m y r l v z L R n

-- TODO: animate, pronouns

--local us=require("ustring/ustring") local us=mw.ustring local u=us.char local s=us.sub local gsub=us.gsub local link = require("Module:links") local lang = require("Module:languages").getByCode("ta")

local export={}

--vowel letters local _A=u(0xb85);local _AA=u(0xb86);local _I=u(0xb87);local _II=u(0xb88);local _U=u(0xb89);local _UU=u(0xb8a);local _E=u(0xb8e);local _EE=u(0xb8f);local _AI=u(0xb90);local _O=u(0xb92);local _OO=u(0xb93);local _AU=u(0xb94) --vowel combining chars local AA=u(0xbbe);local I=u(0xbbf);local II=u(0xbc0);local U=u(0xbc1);local UU=u(0xbc2);local E=u(0xbc6);local EE=u(0xbc7);local AI=u(0xbc8);local O=u(0xbca);local OO=u(0xbcb);local AU=u(0xbcc);local DOT=u(0xbcd) --consonants without dots local kA=u(0xb95);local GA=u(0xb99);local cA=u(0xb9a);local CA=u(0xb9e);local TA=u(0xb9f);local NA=u(0xba3);local tA=u(0xba4);local MA=u(0xba8);local nA=u(0xba9);local pA=u(0xbaa);local mA=u(0xbae);local yA=u(0xbaf);local rA=u(0xbb0);local RA=u(0xbb1);local lA=u(0xbb2);local LA=u(0xbb3);local zA=u(0xbb4);local vA=u(0xbb5)

--convenient regices local vls='['.._A.._AA.._I.._II.._U.._UU.._E.._EE.._AI.._O.._OO.._AU..']' local vcs='['..AA..I..II..U..UU..E..EE..AI..O..OO..AU..']' local svls='['.._A.._I.._U.._E.._O..']' local svcs='['..I..U..E..O..']?' local ks='['..kA..GA..cA..CA..TA..NA..tA..MA..pA..mA..yA..rA..lA..vA..zA..LA..RA..nA..']'

--match function m(q,r) return us.find(q,r)~=nil end

--2 short open function oo(w) k_v=ks..'['..E..I..O..U..']?' return(m(s(w,1,1),'['.._A.._I.._E.._U.._O..']')and m(s(w,2),'^'..k_v..'$'))or(m(w,'^'..k_v..k_v..'$')) end

--combine word ending in konsonant with word beginning in vowel function kv(wk,vw) tr={[_A]='',[_AA]=AA,[_I]=I,[_II]=II,[_U]=U,[_UU]=UU,[_E]=E,[_EE]=EE,[_AI]=AI,[_O]=O,[_OO]=OO,[_AU]=AU} return wk..tr[s(vw,1,1)]..s(vw,2) end

--combine via sandhi ---some rules redundant for our purposes ---chap2, rules 1-8 done (mostly) function c(q,w) if not oo(q)and m(q,U..'$')and m(w,'^'..vls)then return kv(s(q,1,-2),w) elseif m(q,U..'$')and oo(q)and m(w,'^'..vls)then --TODO: atu, itu, etu are exceptions and follow rule 1 instead return kv(q..vA,w) elseif not m(q,U..'$')and(m(q,vcs..'$')or m(q,vls..'$'))and m(w,'^'..vls)then --note: if m(q,'E$'), either 'y' or 'v' can be inserted if m(q,'['..I..II..AI.._I.._II.._AI..']$')then return kv(q..yA,w) else return kv(q..vA,w) end elseif(m(q,'^'..ks..svcs..ks..DOT..'$')or m(q,'^'..svls..ks..DOT..'$'))and m(w,'^'..vls)then return kv(gsub(q,'(.)'..DOT..'$','%0%1'),w) elseif m(q,ks..DOT..'$')and m(w,'^'..vls)then return kv(s(q,0,-2),w) doesn't seem relevant --elseif(m(q,vcs..'$')or m(q,vls..'$'))and m(w,'^['..kA..cA..tA..pA..']')and(q=='aMta'or q=='inta'or q=='enta'or q=='appaTi'or q=='ippaTi'or q=='eppaTi'		or m(w,'^[^ ]') --irrelevant as not dealing with compounds		--or m(q,'Ay$')or m(q,'Aka$')		TODO:check q for dat, acc, inf respectively for below (if needed)		--or m(q,'ku$')or m(q,'Y$')or m(q,'a$'))then --return q..gsub(w,'^ ?([kctp])','%1%0') elseif m(q,'['..nA..lA..NA..LA..']'..DOT..'$')and m(w,'^['..kA..cA..tA..pA..']')then if m(q,'['..nA..lA..']'..DOT..'$')then return gsub(q,'..$',RA..DOT)..w		else return gsub(q,'..$',TA..DOT)..w		end elseif m(q,mA..DOT..'$')then if m(w,'^'..kA)then return gsub(q,'..$',GA..DOT)..w		elseif m(w,'^'..cA)then return gsub(q,'..$',CA..DOT)..w		elseif m(w,'^'..tA)then return gsub(q,'..$',MA..DOT)..w		else return gsub(q,'..$','')..w end else --XXX:my addition, not sure if right return q..w	end end

--oblique stem -- TODO:override for oblique suffix for 1.8 words function obl(s) if m(s,ks..mA..DOT..'$')or m(s,_A..mA..DOT..'$')then return gsub(s,'..$',tA..DOT..tA..U)..'' --XXX:is katti 2 short syllables? elseif m(s,'['..TA..RA..']'..U..'$')and not(m(s,'^'..ks..svcs..ks..svcs..'('..ks..DOT..')?$')or m(s,'^'..svls..ks..svcs..'('..ks..DOT..')?$'))then return gsub(s,'(.).$','%1'..DOT..'%0')..'' else return s	end end

--plural -- TODO:epicene suffix, and gendered nouns function pl(s) --XXX:is katti 2 short syllables? if m(s,'['..AA..EE..II..UU..OO.._AA.._EE.._II.._UU.._OO..']$')or m(s,'^'..ks..svcs..ks..U..'$')or m(s,'^'..svls..ks..U..'$')then return c(s,kA..DOT..kA..LA..DOT) else return c(s,kA..LA..DOT) end end

--conditional plural or oblique function plobl(s,p)if p then return pl(s)else return obl(s)end end

function acc(s,p)return c(plobl(s,p),_AI)end function dat(s,p) stem=plobl(s,p) --XXX: not sure about AU and _AU if(stem~=s or m(s,'['..I..II..AI..AU..U.._I.._II.._AI.._AU.._U..']$'))and not p then return c(stem,kA..DOT..kA..U)	else return c(stem,_U..kA..DOT..kA..U)	end end function ins(s,p)return c(plobl(s,p),_AA..lA..DOT)end --TODO: also _I..lA..DOT for animate function loc(s,p,an) if an then return c(plobl(s,p),_I..TA..mA..DOT) else return c(plobl(s,p),_I..lA..DOT) end end --TODO: also _I..lA..DOT for animate function abl(s,p,an) return c(loc(s,p,an),_I..rA..U..nA..DOT..tA..U) end --TODO: also _U..TA..nA..DOT function soc(s,p) return c(plobl(s,p),_OO..TA..U) end --TODO: also _U..TA..AI..yA and _A..tA..U -- note: potential exceptions with former for some -- also, check when euphonic increment is compulsory -- because currently does not match Arden's gen(maram) function gen(s,p) return c(plobl(s,p),_I..nA..DOT) end function voc(s,p)return c(plobl(s,p),_EE)end

function ln(w) return link.full_link({lang=lang,alt=w},"term") end

function export.conj(frame) mw.log("test") local args = frame:getParent.args local page_title = mw.title.getCurrentTitle.text local w = args[1] or page_title for k, v in pairs(args) do		mw.log(k,v) end mw.log(ln(w)) local ret=[=[ ]=]	return ret end

--maram=mA..rA..mA..DOT --print(pl(maram,1>0)) --print(acc(maram,1<0)) --print(dat(maram,1<0)) --print(ins(maram,1<0)) --print(loc(maram,1<0,1<0)) --print(abl(maram,1<0,1<0)) --print(soc(maram,1<0)) --print(gen(maram,1<0)) --print(voc(maram,1<0))

return export