Module:User:Sarri.greek/el-tin

-- at el.wikationary 2019.05.16. Sarri.greek -- 2024.03.06. wikt:en:User:Sarri.greek -- 2019.07.24. Thanks to Erutuon

-- Recognizes the first letter of a Modern Greek noun (feminine, accusative, singular) -- and produces the correct article την (tin) or τη (ti) -- Called by Template:User:Sarri.greek/el-tin.

local p = {}

-- by Erutuon: remove error "attempt to call method 'getParent' (a nil value)" by accepting string as argument function p.tin(arg) local term if type(arg) == 'table' and type(arg.getParent) == 'function' then local frame = arg local args = frame:getParent.args term = args[1] or '' -- Template:el-tin else term = arg end

PAGENAME = mw.title.getCurrentTitle.text PAGENAME = PAGENAME:match( "^%s*(.-)%s*$" ) -- Do i need this always? It is about trimming empty beginning and end -- when the lemma is a feminine suffix with -xxx -- (1, 1) start at 1st character, stop at 1st character -- when param 1 is empty, see PAGENAME if term:sub(1, 1) == '-' or PAGENAME:sub(1, 1) == "-" then return 'τη(ν)' end

-- when the lemma is a feminine word -- begninning with βδθφχλρσζΒΔΘΦΧΛΡΣΖ return 'τη' if mw.ustring.find(term, '^[βδθφχλρσζΒΔΘΦΧΛΡΣΖ]') or mw.ustring.find(PAGENAME, '^[βδθφχλρσζΒΔΘΦΧΛΡΣΖ]') then return 'τη' else -- μ - μπ if mw.ustring.find(term, '^[μΜ][πΠ]') or mw.ustring.find(PAGENAME, '^[μΜ][πΠ]') then return 'την' else if mw.ustring.find(term, '^[μΜ]') then return 'τη' end end -- ν - ντ if mw.ustring.find(term, '^[νΝ][τΤ]') or mw.ustring.find(PAGENAME, '^[νΝ][τΤ]') then return 'την' else if mw.ustring.find(term, '^[νΝ]') then return 'τη' end end -- γ - γκ if mw.ustring.find(term, '^[γΓ][κΚ]') then return 'την' else if mw.ustring.find(term, '^[γΓ]') or mw.ustring.find(PAGENAME, '^[γΓ]') then return 'τη'	end end -- else, if NOT begninning with βδθφχλρσζΒΓΔΘΦΧΛΡΣΖ return 'τηv' return 'την' end --close beginning with... end --close function

-- the same function for transliteration function p.tin_translit(arg) --p['tin-translit'] = function(arg) local term if type(arg) == 'table' and type(arg.getParent) == 'function' then local frame = arg local args = frame:getParent.args term = args[1] or '' -- Template:el-tin else term = arg end

PAGENAME = mw.title.getCurrentTitle.text PAGENAME:match( "^%s*(.-)%s*$" ) -- Do i need this always? It is about trimming empty beginning and end -- when the lemma is a feminine suffix with -xxx -- (1, 1) start at 1st character, stop at 1st character -- when param 1 is empty, see PAGENAME if term:sub(1, 1) == '-' or PAGENAME:sub(1, 1) == "-" then return 'tī(n)' end

-- when the lemma is a feminine word -- begninning with βδθφχλρσζΒΔΘΦΧΛΡΣΖ return 'τη' if mw.ustring.find(term, '^[βδθφχλρσζΒΔΘΦΧΛΡΣΖ]') or mw.ustring.find(PAGENAME, '^[βδθφχλρσζΒΔΘΦΧΛΡΣΖ]') then return 'tī' else -- μ - μπ if mw.ustring.find(term, '^[μΜ][πΠ]') or mw.ustring.find(PAGENAME, '^[μΜ][πΠ]') then return 'tīn' else if mw.ustring.find(term, '^[μΜ]') then return 'tī' end end -- ν - ντ if mw.ustring.find(term, '^[νΝ][τΤ]') or mw.ustring.find(PAGENAME, '^[νΝ][τΤ]') then return 'tīn' else if mw.ustring.find(term, '^[νΝ]') then return 'tī' end end -- γ - γκ if mw.ustring.find(term, '^[γΓ][κΚ]') then return 'tīn' else if mw.ustring.find(term, '^[γΓ]') or mw.ustring.find(PAGENAME, '^[γΓ]') then return 'tī'	end end -- else, if NOT begninning with βδθφχλρσζΒΓΔΘΦΧΛΡΣΖ return 'τηv' return 'tīn' end --close beginning with... end --close function

return p