Module:km-etym

-- Read the documentation before any change.

local export = {} local gsub = mw.ustring.gsub local sub = mw.ustring.sub local match = mw.ustring.match local namespace = mw.title.getCurrentTitle.nsText -- 0 = redup, 1 = prefix, 2 = infix local affixes = { ["R-"] = 0, ["p-"] = 1, ["t-"] = 1, ["c-"] = 1, ["k-"] = 1, ["s-"] = 1, ["r-"] = 1, ["l-"] = 1, ["m-"] = 1, --["RrV-"] = 1, ["prV-"] = 1, ["trV-"] = 1, ["crV-"] = 1, ["krV-"] = 1, ["srV-"] = 1, --["RVN-"] = 1, ["bVN-"] = 1, ["dVN-"] = 1, ["cVN-"] = 1, ["kVN-"] = 1, ["sVN-"] = 1, ["rVN-"] = 1, ["lVN-"] = 1, ["aN-"] = 1, ["-b-"] = 2, ["-m-"] = 2, ["-n-"] = 2, ["-r-"] = 2, ["-l-"] = 2, ["-h-"] = 2, -- The following two are allomorphs, should be merged? ["-VN-"] = 2, ["-Vmn-"] = 2, -- The following two are allomorphs of -n- and -m-, keeping them separate for now ["-rVn-"] = 2, ["-rVm-"] = 2}

-- Not used local affixes_km = { ["R-"] = 0, ["ប-"] = 1, ["ត-"] = 1, ["ច-"] = 1, ["ក-"] = 1, ["ស-"] = 1, ["រ-"] = 1, ["ល-"] = 1, ["ម-"] = 1, ["ប្រ-"] = 1, ["ត្រ-"] = 1, ["ច្រ-"] = 1, ["ក្រ-"] = 1, ["ស្រ-"] = 1, ["បំ-"] = 1, ["ដំ-"] = 1, ["ចំ-"] = 1, ["កំ-"] = 1, ["សំ-"] = 1, ["រំ-"] = 1, ["លំ-"] = 1, ["-ប-"] = 2, ["-ម-"] = 2, ["-ន-"] = 2, ["-រ-"] = 2, ["-ល-"] = 2, ["-◌ំ-"] = 2, ["-◌ំន-"] = 2, ["-រន-"] = 2} --

-- Important: local functions ={ -- Valency modifiers, verbalizations ["caus"] = "causative",     -- factitive, transitivizing ["recip"] = "reciprocal", ["attrib"]= "attributive",  -- qualitative, adjectival -- Semantic shifts ["spec"] = "specializing",  -- similative, figurative, directional, -- sometimes no particular meaning added -- more of a catch-all category ["intens"]= "intensive",    -- emphatic, directional, augmentative ["rep"]  = "repetitive",    -- frequentative, habitual, distributive -- Nominalizations ["agent"] = "agentive", ["instr"] = "instrumental", ["loc"]  = "locative", ["proc"] = "processive",    -- action noun, gerund, sometimes resultative too ["res"]  = "resultative", -- Numbers ["sing"] = "singularizing", ["coll"] = "collective" }
 * 1) Since Khmer words can very easily slide from noun to adj to verb to adverb without any overt morphological change, functions should be named based on how affixes affects the *meaning* of the base root, not on how it makes it change parts of speech.
 * 2) As a consequence, do NOT create functions called "nominalization", "verbalizations", etc...

-- redup local redup_modes = { ["rhy"] = "rhyming", ["rhyme"] = "rhyming", ["allit"] = "alliterative", ["ablaut"] = "ablauting" --[nil]="", --used for total reduplication }

function get_redup_mode(mode) if mode == nil or mode == "" then return "reduplication" end mode_text = redup_modes[mode] if mode_text == nil then error("Reduplication mode could not be recognized") end

mode_text = mode_text.. " reduplication" return mode_text end

function get_base_only_text(root) text="" if root ~= nil and root ~= "" and root ~= "-" and sub(root, 1,1) == "-" then text =" This base is only found in derived forms." end return text end

function export.affix(frame) local args = frame:getParent.args

root = args[1] gloss = args[2] affix = args[3] or args["af"] func = args[4] ultim = args["ultim"] compound = args["compound"] nocap =args["nocap"] nopunct =args["nopunct"] tr = args["tr"] affix2 = args["af2"]

root_text = "" if root == "-" then root_text = "form" elseif root ~= nil and root ~= "" then root_text = "from " .. frame:expandTemplate{ title = "m", args = {"km", root, nil, gloss = gloss, sc = "Khmr", tr = tr}} end

affix_text = "" affix_cat_text = "" affix_type = affixes[affix] or error("Affix could not be recognized") if affix_type == 0 then affix_text = "reduplicated initial" affix_cat_text = affix_text else if affix_type == 1 then affix_text = "prefixed" elseif affix_type == 2 then affix_text = "infixed" end affix_cat_text = affix_text .. " ".. affix affix_text = affix_text.. " ".. affix.. "" end

-- make a function... affix2_text = "" affix2_cat_text = "" if affix2 ~= nil then affix2_type = affixes[affix2] or error("Affix2 could not be recognized") if affix2_type == 0 then affix2_text = "reduplicated initial" affix2_cat_text = affix2_text else if affix2_type == 1 then affix2_text = "prefixed" elseif affix2_type == 2 then affix2_text = "infixed" end affix2_cat_text = affix2_text .. " ".. affix2 affix2_text = affix2_text.. " ".. affix2.. "" end affix2_text = " and ".. affix2_text end

func_string = "" func_text = "" if func ~= nil then func_string = functions[func] or error("Function could not be recognized") end if func_string ~= "" then func_text = " (" .. func_string .. ")" end compound_text = "" redup_text ="" if compound ~= nil then compound_text = ", applied to each term of the" if compound=="1" then compound_text = compound_text.. " compound" else redup_text= get_redup_mode(compound) compound_text = compound_text.. " ".. redup_text end end

ultim_text = "" if ultim ~= nil then ultim_text = ", ultimately from ".. frame:expandTemplate{ title = "m", args = {"km", ultim, nil, gloss = nil, sc = "Khmr"}} end

if root_text ~= "" then text = root_text text = text .. " with " text = text .. affix_text.. func_text text = text .. affix2_text text = text .. compound_text text = text .. ultim_text

if nopunct == nil then text = text .. "."       end

text = text.. get_base_only_text(root)

if nocap == nil then text = mw. getContentLanguage:ucfirst(text) end

else text="".. affix.. "" end

-- Categories if namespace == "" then -- Will activate affix categories later -- text = text..""

if affix2 ~= nil then -- text = text.."" end -- will activate function categories later if func_string ~= "" then -- text = text.."" end

if compound ~= nil then if compound == "1" then text = text.."" elseif redup_text ~= nil then text = text.. ""   	end --text = text.."" end end return text end

function export.redup(frame) local args = frame:getParent.args

lemma= args[1] gloss= args[2] mode = args[3] or args["type"] lemma2 = args["l2"] gloss2 = args["t2"] tr = args["tr"] nocap =args["nocap"]

mode_text = get_redup_mode(mode) article = "a" if sub(mode_text, 1, 1) == "a" then article = "an" end

text = ""

-- when lemma isn't provided, it is assumed it comes after a template, that this module further qualifies.

if lemma == nil or lemma == "" then text = mode_text nocap = 1 else text = mode_text.. " of ".. frame:expandTemplate{ title = "m", args = {"km", lemma, nil, gloss = gloss, sc = "Khmr", tr = tr}} .. "."   end --   text = text.. get_base_only_text(lemma)

-- case of coincidental echo word if lemma2 ~= nil then if lemma == nil or lemma == "" then error("Argument l2 can't be used if argument 1 is not also provided") end

text = text.." The identification of the echo syllable with "..frame:expandTemplate{ title = "m", args = {"km", lemma2, nil, gloss = gloss2, sc = "Khmr"}}.. " is coincidental, and no meaning is carried over from it." end if nocap == nil then text = mw.getContentLanguage:ucfirst(text) end

-- Categories if namespace == "" then text = text.."" if lemma == nil or lemma == "" then -- Note: not always found in synonymous compounds, eg. ធីងធៅង from onomatopoeic source, or ពីងពាង from mkh-pro --text = text.."" end end return text end

return export