Module:User:ZxxZxxZ/ar-verb
Jump to navigation
Jump to search
- This module sandbox lacks a documentation subpage. You may create it.
- Useful links: root page • root page’s subpages • links • transclusions • testcases • user page • user talk page • userspace
This is a private module sandbox of ZxxZxxZ, for his own experimentation. Items in this module may be added and removed at ZxxZxxZ's discretion; do not rely on this module's stability.
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 .. "[[Category:" .. cat .. "|" .. sort_key .. "]]"
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 = "<br/>"
for key, form in pairs(forms) do
-- check for empty strings and nil's
if form ~= "" and form then
--text = key .. [=[: {{Arab|]=] .. forms[key] .. [=[}}{{LR}}, ]=]
text = text .. key .. ": " .. forms[key] .. ", <br/>"
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 = [=[<div class="NavFrame" style="width:100%">
<div class="NavHead" style="height:2.5em">]=] .. title .. [=[</div>
<div class="NavContent">
{| border="1" color="#cdcdcd" style="border-collapse:collapse; line-height:2.5em; border:1px solid #555555; background:#fdfdfd; width:100%; text-align:center" class="inflection-table"
|-
! colspan="6" style="background:#dedede" | verbal noun]=] .. (forms["vn2"] and "s" or "") .. "<br />" .. com.tag_text(forms["vn2"] and "المصادر" or "المصدر") .. [=[
| colspan="7" | ]=] .. forms["vn"] .. (forms["vn2"] and ", " .. forms["vn2"] or "") .. [=[
|-
! colspan="6" style="background:#dedede" | active participle<br />]=] .. com.tag_text("اسم الفاعل") .. [=[
| colspan="7" | ]=] .. forms["ap"]
if passive then
text = text .. [=[
|-
! colspan="6" style="background:#dedede" | passive participle<br />]=] .. com.tag_text("اسم المفعول") .. [=[
| colspan="7" | ]=] .. forms["pp"]
end
text = text ..[=[
|-
! colspan="12" style="background:#bcbcbc" | active voice<br />]=] .. com.tag_text("الفعل المعلوم") .. [=[
|-
! colspan="2" style="background:#cdcdcd" |
! colspan="3" style="background:#cdcdcd" | singular<br />]=] .. com.tag_text("المفرد") .. [=[
! rowspan="12" style="background:#cdcdcd;width:.5em" |
! colspan="2" style="background:#cdcdcd" | dual<br />]=] .. com.tag_text("المثنى") .. [=[
! rowspan="12" style="background:#cdcdcd;width:.5em" |
! colspan="3" style="background:#cdcdcd" | plural<br />]=] .. com.tag_text("الجمع") .. [=[
|-
! colspan="2" style="background:#cdcdcd" |
! style="background:#cdcdcd" | 1<sup>st</sup> person<br />]=] .. com.tag_text("المتكلم") .. [=[
! style="background:#cdcdcd" | 2<sup>nd</sup> person<br />]=] .. com.tag_text("المخاطب") .. [=[
! style="background:#cdcdcd" | 3<sup>rd</sup> person<br />]=] .. com.tag_text("الغائب") .. [=[
! style="background:#cdcdcd" | 2<sup>nd</sup> person<br />]=] .. com.tag_text("المخاطب") .. [=[
! style="background:#cdcdcd" | 3<sup>rd</sup> person<br />]=] .. com.tag_text("الغائب") .. [=[
! style="background:#cdcdcd" | 1<sup>st</sup> person<br />]=] .. com.tag_text("المتكلم") .. [=[
! style="background:#cdcdcd" | 2<sup>nd</sup> person<br />]=] .. com.tag_text("المخاطب") .. [=[
! style="background:#cdcdcd" | 3<sup>rd</sup> person<br />]=] .. com.tag_text("الغائب") .. [=[
|-
! rowspan="2" style="background:#cdcdcd" | perfect indicative<br />]=] .. com.tag_text("الماضي") .. [=[
! style="background:#dedede" | ''m''
| rowspan="2" | ]=] .. forms["1s-perf"] .. [=[
| ]=] .. forms["2sm-perf"] .. [=[
| rowspan="2" | ]=] .. forms["2d-perf"] .. [=[
| ]=] .. forms["3dm-perf"] .. [=[
| rowspan="2" | ]=] .. forms["1p-perf"] .. [=[
| ]=] .. forms["2pm-perf"] .. [=[
| ]=] .. forms["3pm-perf"] .. [=[
|-
! style="background:#dedede" | ''f''
| ]=] .. forms["2sf-perf"] .. [=[
| ]=] .. forms["3sf-perf"] .. [=[
| ]=] .. forms["3df-perf"] .. [=[
| ]=] .. forms["2pf-perf"] .. [=[
| ]=] .. forms["3pf-perf"] .. [=[
|-
! rowspan="2" style="background:#cdcdcd" | imperfect indicative<br />]=] .. com.tag_text("المضارع") .. [=[
! style="background:#dedede" | ''m''
| rowspan="2" | ]=] .. forms["1s-impf"] .. [=[
| ]=] .. forms["2sm-impf"] .. [=[
| ]=] .. forms["3sm-impf"] .. [=[
| rowspan="2" | ]=] .. forms["2d-impf"] .. [=[
| ]=] .. forms["3dm-impf"] .. [=[
| rowspan="2" | ]=] .. forms["1p-impf"] .. [=[
| ]=] .. forms["2pm-impf"] .. [=[
| ]=] .. forms["3pm-impf"] .. [=[
|-
! style="background:#dedede" | ''f''
| ]=] .. forms["2sf-impf"] .. [=[
| ]=] .. forms["3sf-impf"] .. [=[
| ]=] .. forms["3df-impf"] .. [=[
| ]=] .. forms["2pf-impf"] .. [=[
| ]=] .. forms["3pf-impf"] .. [=[
|-
! rowspan="2" style="background:#cdcdcd" | subjunctive<br />]=] .. com.tag_text("المضارع المنصوب") .. [=[
! style="background:#dedede" | ''m''
| rowspan="2" | ]=] .. forms["1s-subj"] .. [=[
| ]=] .. forms["2sm-subj"] .. [=[
| ]=] .. forms["3sm-subj"] .. [=[
| rowspan="2" | ]=] .. forms["2d-subj"] .. [=[
| ]=] .. forms["3dm-subj"] .. [=[
| rowspan="2" | ]=] .. forms["1p-subj"] .. [=[
| ]=] .. forms["2pm-subj"] .. [=[
| ]=] .. forms["3pm-subj"] .. [=[
|-
! style="background:#dedede" | ''f''
| ]=] .. forms["2sf-subj"] .. [=[
| ]=] .. forms["3sf-subj"] .. [=[
| ]=] .. forms["3df-subj"] .. [=[
| ]=] .. forms["2pf-subj"] .. [=[
| ]=] .. forms["3pf-subj"] .. [=[
|-
! rowspan="2" style="background:#cdcdcd" | jussive<br />]=] .. com.tag_text("المضارع المجزوم") .. [=[
! style="background:#dedede" | ''m''
| rowspan="2" | ]=] .. forms["1s-juss"] .. [=[
| ]=] .. forms["2sm-juss"] .. [=[
| ]=] .. forms["3sm-juss"] .. [=[
| rowspan="2" | ]=] .. forms["2d-juss"] .. [=[
| ]=] .. forms["3dm-juss"] .. [=[
| rowspan="2" | ]=] .. forms["1p-juss"] .. [=[
| ]=] .. forms["2pm-juss"] .. [=[
| ]=] .. forms["3pm-juss"] .. [=[
|-
! style="background:#dedede" | ''f''
| ]=] .. forms["2sf-juss"] .. [=[
| ]=] .. forms["3sf-juss"] .. [=[
| ]=] .. forms["3df-juss"] .. [=[
| ]=] .. forms["2pf-juss"] .. [=[
| ]=] .. forms["3pf-juss"] .. [=[
|-
! rowspan="2" style="background:#cdcdcd" | imperative<br />]=] .. com.tag_text("الأمر") .. [=[
! style="background:#dedede" | ''m''
| rowspan="2" |
| ]=] .. forms["2sm-impr"] .. [=[
| rowspan="2" |
| rowspan="2" | ]=] .. forms["2d-impr"] .. [=[
| rowspan="2" |
| rowspan="2" |
| ]=] .. forms["2pm-impr"] .. [=[
| rowspan="2" |
|-
! style="background:#dedede" | ''f''
| ]=] .. forms["2sf-impr"] .. [=[
| ]=] .. forms["2pf-impr"]
if passive then
text = text .. [=[
|-
! colspan="12" style="background:#bcbcbc" | passive voice<br />]=] .. com.tag_text("الفعل المجهول") .. [=[
|-
| colspan="2" style="background:#cdcdcd" |
! colspan="3" style="background:#cdcdcd" | singular<br />]=] .. com.tag_text("المفرد") .. [=[
| rowspan="10" style="background:#cdcdcd;width:.5em" |
! colspan="2" style="background:#cdcdcd" | dual<br />]=] .. com.tag_text("المثنى") .. [=[
| rowspan="10" style="background:#cdcdcd;width:.5em" |
! colspan="3" style="background:#cdcdcd" | plural<br />]=] .. com.tag_text("الجمع") .. [=[
|-
| colspan="2" style="background:#cdcdcd" |
! style="background:#cdcdcd" | 1<sup>st</sup> person<br />]=] .. com.tag_text("المتكلم") .. [=[
! style="background:#cdcdcd" | 2<sup>nd</sup> person<br />]=] .. com.tag_text("المخاطب") .. [=[
! style="background:#cdcdcd" | 3<sup>rd</sup> person<br />]=] .. com.tag_text("الغائب") .. [=[
! style="background:#cdcdcd" | 2<sup>nd</sup> person<br />]=] .. com.tag_text("المخاطب") .. [=[
! style="background:#cdcdcd" | 3<sup>rd</sup> person<br />]=] .. com.tag_text("الغائب") .. [=[
! style="background:#cdcdcd" | 1<sup>st</sup> person<br />]=] .. com.tag_text("المتكلم") .. [=[
! style="background:#cdcdcd" | 2<sup>nd</sup> person<br />]=] .. com.tag_text("المخاطب") .. [=[
! style="background:#cdcdcd" | 3<sup>rd</sup> person<br />]=] .. com.tag_text("الغائب") .. [=[
|-
! rowspan="2" style="background:#cdcdcd" | perfect indicative<br />]=] .. com.tag_text("الماضي") .. [=[
! style="background:#dedede" | ''m''
| rowspan="2" | ]=] .. forms["1s-ps-perf"] .. [=[
| ]=] .. forms["2sm-ps-perf"] .. [=[
| rowspan="2" | ]=] .. forms["2d-ps-perf"] .. [=[
| ]=] .. forms["3dm-ps-perf"] .. [=[
| rowspan="2" | ]=] .. forms["1p-ps-perf"] .. [=[
| ]=] .. forms["2pm-ps-perf"] .. [=[
| ]=] .. forms["3pm-ps-perf"] .. [=[
|-
! style="background:#dedede" | ''f''
| ]=] .. forms["2sf-ps-perf"] .. [=[
| ]=] .. forms["3sf-ps-perf"] .. [=[
| ]=] .. forms["3df-ps-perf"] .. [=[
| ]=] .. forms["2pf-ps-perf"] .. [=[
| ]=] .. forms["3pf-ps-perf"] .. [=[
|-
! rowspan="2" style="background:#cdcdcd" | imperfect indicative<br />]=] .. com.tag_text("المضارع") .. [=[
! style="background:#dedede" | ''m''
| rowspan="2" | ]=] .. forms["1s-ps-impf"] .. [=[
| ]=] .. forms["2sm-ps-impf"] .. [=[
| ]=] .. forms["3sm-ps-impf"] .. [=[
| rowspan="2" | ]=] .. forms["2d-ps-impf"] .. [=[
| ]=] .. forms["3dm-ps-impf"] .. [=[
| rowspan="2" | ]=] .. forms["1p-ps-impf"] .. [=[
| ]=] .. forms["2pm-ps-impf"] .. [=[
| ]=] .. forms["3pm-ps-impf"] .. [=[
|-
! style="background:#dedede" | ''f''
| ]=] .. forms["2sf-ps-impf"] .. [=[
| ]=] .. forms["3sf-ps-impf"] .. [=[
| ]=] .. forms["3df-ps-impf"] .. [=[
| ]=] .. forms["2pf-ps-impf"] .. [=[
| ]=] .. forms["3pf-ps-impf"] .. [=[
|-
! rowspan="2" style="background:#cdcdcd" | subjunctive<br />]=] .. com.tag_text("المضارع المنصوب") .. [=[
! style="background:#dedede" | ''m''
| rowspan="2" | ]=] .. forms["1s-ps-subj"] .. [=[
| ]=] .. forms["2sm-ps-subj"] .. [=[
| ]=] .. forms["3sm-ps-subj"] .. [=[
| rowspan="2" | ]=] .. forms["2d-ps-subj"] .. [=[
| ]=] .. forms["3dm-ps-subj"] .. [=[
| rowspan="2" | ]=] .. forms["1p-ps-subj"] .. [=[
| ]=] .. forms["2pm-ps-subj"] .. [=[
| ]=] .. forms["3pm-ps-subj"] .. [=[
|-
! style="background:#dedede" | ''f''
| ]=] .. forms["2sf-ps-subj"] .. [=[
| ]=] .. forms["3sf-ps-subj"] .. [=[
| ]=] .. forms["3df-ps-subj"] .. [=[
| ]=] .. forms["2pf-ps-subj"] .. [=[
| ]=] .. forms["3pf-ps-subj"] .. [=[
|-
! rowspan="2" style="background:#cdcdcd" | jussive<br />]=] .. com.tag_text("المضارع المجزوم") .. [=[
! style="background:#dedede" | ''m''
| rowspan="2" | ]=]
text = text .. forms["1s-ps-juss"] .. [=[
| ]=] .. forms["2sm-ps-juss"] .. [=[
| ]=] .. forms["3sm-ps-juss"] .. [=[
| rowspan="2" | ]=] .. forms["2d-ps-juss"] .. [=[
| ]=] .. forms["3dm-ps-juss"] .. [=[
| rowspan="2" | ]=] .. forms["1p-ps-juss"] .. [=[
| ]=] .. forms["2pm-ps-juss"] .. [=[
| ]=] .. forms["3pm-ps-juss"] .. [=[
|-
! style="background:#dedede" | ''f''
| ]=] .. forms["2sf-ps-juss"] .. [=[
| ]=] .. forms["3sf-ps-juss"] .. [=[
| ]=] .. forms["3df-ps-juss"] .. [=[
| ]=] .. forms["2pf-ps-juss"] .. [=[
| ]=] .. forms["3pf-ps-juss"]
end
text = text .. [=[
|}
</div>
</div>]=]
return text
end
return export