Module:User:ZxxZxxZ/ar-verb

local com = require("Module:ar-common") local export = {} local conjugations = {} local dia = { s = "ْ", a = "َ", i = "ِ", u = "ُ", sh_a = "َّ", sh_i = "ِّ", sh_u = "ُّ" } local translit = { ["ف"] = "f", ["ع"] = "ʿ", ["ل"] = "l", ["ك"] = "k", ["ت"] = "t", ["ب"] = "b", ["ج"] = "j", ["د"] = "d", -- TODO } -- Within this module, conjugations are the functions that do the actual -- conjugating by creating the forms of a basic verb. -- They are defined further down. local conjugations = {} -- The main entry point. -- This is the only function that can be invoked from a template. function export.show(frame) local conj_type = frame.args[1] or error("Conjugation type has not been specified. Please pass parameter 1 to the module invocation") local args = frame:getParent.args PAGENAME = mw.title.getCurrentTitle.text NAMESPACE = mw.title.getCurrentTitle.nsText --if this named parameter passed, make the verb intransitive, passive forms don't exist local intrans = args["intrans"] local intr = (verb_type == "intr") local forms, title, categories if conjugations[conj_type] then forms, title, categories = conjugations[conj_type](args) else error("Unknown conjugation type '" .. conj_type .. "'") end -- transitive/intransitive if intrans then table.insert(categories, "Arabic intransitive verbs") else table.insert(categories, "Arabic transitive verbs") end local ret = "" if NAMESPACE == "" then local sort_key = com.sort_key(PAGENAME) for key, cat in ipairs(categories) do           ret = ret .. ""       end end -- temp comment until form is fixed return make_table(forms, title, intrans) .. ret -- temporary, for testing forms only --return test_forms(forms, title, intrans) .. ret end --[=[   Conjugation functions ]=]-- conjugations["I"] = function(args) local forms, forms_tr = {}, {} local categories = {"Arabic form-I verbs"} local title = "form I"   -- for sound verbs in form I need to provide three radical consonants and two vowels - perfective and imperective local rad1 = args[1] or "ف" local rad2 = args[2] or "ع" local rad3 = args[3] or "ل" local pf_vowel = args[4] or "a" local impf_vowel = args[5] or "a" -- Verbal nouns (maṣādir) for form I are upredictable and have to be supplied forms["vn"] = args["vn"] or "" forms["vn2"] = args["vn2"] or "" --e.g. k, t, b for كتب local rad1_tr, rad2_tr, rad3_tr = translit[rad1], translit[rad2], translit[rad3] -- will only need to attach past stem ending to this variable local past_stem = rad1 .. dia["a"] .. rad2 .. dia[pf_vowel] .. rad3 local past_stem_tr = rad1_tr .. "a" .. rad2_tr .. pf_vowel .. rad3_tr local pres_stem = rad1 .. dia.s .. rad2 .. dia[impf_vowel] .. rad3 local pres_stem_tr = rad1_tr .. rad2_tr .. impf_vowel .. rad3_tr local conj_stem = "" local conj_stem_tr = "" local juss_stem = "" local juss_stem_tr = "" local ps_perf_stem = "" local ps_perf_stem_tr = "" local imper_stem = "" local imper_stem_tr = "" -- make perfective forms forms = export.perfective_conj(forms, past_stem) forms = export.imperfective_conj(forms, pres_stem) forms = export.subjunctive_conj(forms, conj_stem) forms = export.jussive_conj(forms, juss_stem) forms = export.pass_perfective_conj(forms, ps_perf_stem) forms = export.pass_imperfective_conj(forms, ps_perf_stem) forms = export.pass_subjunctive_conj(forms, ps_perf_stem) forms = export.pass_jussive_conj(forms, ps_perf_stem) forms = export.make_imperative(forms, imper_stem) -- to do   forms["ap"] = "" forms["pp"] = "" return forms, title, categories--, forms_tr end -- functions to add ending to stems -- can be reused for all perfective forms with sound endings function export.perfective_conj(forms, past_stem) -- singular forms["3sm-perf"] = past_stem .."َ" forms["3sf-perf"] = past_stem .."َتْ" forms["2sm-perf"] = past_stem .."ْتَ" forms["2sf-perf"] = past_stem .."ْتِ" forms["1s-perf"] = past_stem .."ْتُ" --dual forms["3dm-perf"] = past_stem .."َا" forms["3df-perf"] = past_stem .."َتَا" forms["2d-perf"] = past_stem .."ْتُمَا" -- plural forms["3pm-perf"] = past_stem .."ُوا" forms["3pf-perf"] = past_stem .."ْنَ" forms["2pm-perf"] = past_stem .."ْتُمْ" forms["2pf-perf"] = past_stem .."ْتُنَّ" forms["1p-perf"] = past_stem .."ْنَا" --forms_tr["3sm-perf"] = past_stem_tr .. "a" return forms--, forms_tr end -- can be reused for all imperfective forms with sound endings function export.imperfective_conj(forms, pres_stem) -- to do   forms["1s-impf"] = "" forms["2sm-impf"] = "" forms["3sm-impf"] = "" forms["2d-impf"] = "" forms["3dm-impf"] = "" forms["1p-impf"] = "" forms["2pm-impf"] = "" forms["3pm-impf"] = "" forms["2sf-impf"] = "" forms["3sf-impf"] = "" forms["3df-impf"] = "" forms["2pf-impf"] = "" forms["3pf-impf"] = "" return forms end -- can be reused for all subjunctive forms with sound endings function export.subjunctive_conj(forms, conj_stem) -- to do   forms["1s-subj"] = "" forms["2sm-subj"] = "" forms["3sm-subj"] = "" forms["2d-subj"] = "" forms["3dm-subj"] = "" forms["1p-subj"] = "" forms["2pm-subj"] = "" forms["3pm-subj"] = "" forms["2sf-subj"] = "" forms["3sf-subj"] = "" forms["3df-subj"] = "" forms["2pf-subj"] = "" forms["3pf-subj"] = "" return forms end -- can be reused for all jussive forms with sound endings function export.jussive_conj(forms, juss_stem) -- to do   forms["1s-juss"] = "" forms["2sm-juss"] = "" forms["3sm-juss"] = "" forms["2d-juss"] = "" forms["3dm-juss"] = "" forms["1p-juss"] = "" forms["2pm-juss"] = "" forms["3pm-juss"] = "" forms["2sf-juss"] = "" forms["3sf-juss"] = "" forms["3df-juss"] = "" forms["2pf-juss"] = "" forms["3pf-juss"] = "" return forms end -- can be reused for all passive perfective forms with sound endings function export.pass_perfective_conj(forms, ps_perf_stem) -- to do   forms["1s-ps-perf"] = "" forms["2sm-ps-perf"] = "" forms["2d-ps-perf"] = "" forms["3dm-ps-perf"] = "" forms["1p-ps-perf"] = "" forms["2pm-ps-perf"] = "" forms["3pm-ps-perf"] = "" forms["2sf-ps-perf"] = "" forms["3sf-ps-perf"] = "" forms["3df-ps-perf"] = "" forms["2pf-ps-perf"] = "" forms["3pf-ps-perf"] = "" return forms end -- can be reused for all passive imperfective forms with sound endings function export.pass_imperfective_conj(forms, ps_perf_stem) -- to do   forms["1s-ps-impf"] = "" forms["2sm-ps-impf"] = "" forms["3sm-ps-impf"] = "" forms["2d-ps-impf"] = "" forms["3dm-ps-impf"] = "" forms["1p-ps-impf"] = "" forms["2pm-ps-impf"] = "" forms["3pm-ps-impf"] = "" forms["2sf-ps-impf"] = "" forms["3sf-ps-impf"] = "" forms["3df-ps-impf"] = "" forms["2pf-ps-impf"] = "" forms["3pf-ps-impf"] = "" return forms end -- can be reused for all passive subjunctive forms with sound endings function export.pass_subjunctive_conj(forms, ps_perf_stem) -- to do   forms["1s-ps-subj"] = "" forms["2sm-ps-subj"] = "" forms["3sm-ps-subj"] = "" forms["2d-ps-subj"] = "" forms["3dm-ps-subj"] = "" forms["1p-ps-subj"] = "" forms["2pm-ps-subj"] = "" forms["3pm-ps-subj"] = "" forms["2sf-ps-subj"] = "" forms["3sf-ps-subj"] = "" forms["3df-ps-subj"] = "" forms["2pf-ps-subj"] = "" forms["3pf-ps-subj"] = "" return forms end -- can be reused for all passive jussive forms with sound endings function export.pass_jussive_conj(forms, ps_perf_stem) -- to do   forms["1s-ps-juss"] = "" forms["2sm-ps-juss"] = "" forms["3sm-ps-juss"] = "" forms["2d-ps-juss"] = "" forms["3dm-ps-juss"] = "" forms["1p-ps-juss"] = "" forms["2pm-ps-juss"] = "" forms["3pm-ps-juss"] = "" forms["2sf-ps-juss"] = "" forms["3sf-ps-juss"] = "" forms["3df-ps-juss"] = "" forms["2pf-ps-juss"] = "" forms["3pf-ps-juss"] = "" return forms end -- can be reused for all imperative forms with sound endings function export.make_imperative(forms, imper_stem) -- to do   forms["2sm-impr"] = "" forms["2d-impr"] = "" forms["2pm-impr"] = "" forms["2sf-impr"] = "" forms["2pf-impr"] = "" return forms end -- Test function test_forms(forms, title, intr) local text = " " for key, form in pairs(forms) do       -- check for empty strings and nil's        if form ~= "" and form then --text = key .. [=[:, ]=]            text = text .. key .. ": " .. forms[key] .. ", "        end end return text end -- Make the table function make_table(forms, title, intr) local title = "Conjugation of ''" .. forms["3sm-perf"] .. "''" .. (title and " (" .. title .. ")" or "") local title_tr = "TO ADD TRANSLITERATION OF THE TITLE" local passive = true local text = [=[ ]=] .. title .. [=[ ]=]   return text end return export