Module:snon-headword: Difference between revisions

No edit summary
No edit summary
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
local export = {}
local export = {}
local pos_functions = {}
local pos_functions = {}
local match = mw.ustring.match
local gsub = mw.ustring.gsub


local m_links = require("Module:links")
local m_links = require("Module:links")
Line 40: Line 43:
["head"] = {list = true, disallow_holes = true},
["head"] = {list = true, disallow_holes = true},
["nomut"] = {type = "boolean"},
["nomut"] = {type = "boolean"},
["type"] = {set = {"b", "s"}, default = "b"},
}
}


Line 81: Line 85:
"m-s", "f-s", "mf-s", "mfbysense-s", "mfequiv-s", "gneut-s", "n-s",
"m-s", "f-s", "mf-s", "mfbysense-s", "mfequiv-s", "gneut-s", "n-s",
"?", "?-p", "?-s"
"?", "?-p", "?-s"
}
-- Extensible table for default plural endings by gender
local default_plural_endings = {
m = "ar",
f = "ir",
-- Easily add more later, e.g., n = "ur"
}
}


Line 101: Line 98:
end
end


-- Extracts the base gender ("m", "f", etc.) ignoring number suffixes like "-p" or "-s"
 
local function get_base_gender(g)
if type(g) == "table" then g = g.spec end
g = g:gsub("%-p$", ""):gsub("%-s$", "")
if g == "mf" then return {"m", "f"} end
if default_plural_endings[g] then return {g} end
return {}
end


local function do_noun(args, data, is_proper)
local function do_noun(args, data, is_proper)
local default_plural_endings = {
m = (args.type == "s" and "e" or "") .. "ar",
f = (args.type == "b" and "á" or "") .. "ir",
}
-- Extracts the base gender ("m", "f", etc.) ignoring number suffixes like "-p" or "-s"
local function get_base_gender(g)
if type(g) == "table" then g = g.spec end
g = g:gsub("%-p$", ""):gsub("%-s$", "")
if g == "mf" then return {"m", "f"} end
if default_plural_endings[g] then return {g} end
return {}
end
local is_plurale_tantum = false
local is_plurale_tantum = false
local category_pos = m_en_util.singularize(data.pos_category)
local category_pos = m_en_util.singularize(data.pos_category)
Line 316: Line 320:
end
end


process_adj_form("comp", "ar", "comparative", "comp")
process_adj_form("comp", (args.type == "s" and "e" or "") .. "ar", "comparative", "comp")
process_adj_form("sup", "ast", "superlative", "sup")
process_adj_form("sup", (args.type == "s" and "e" or "") .. "ast", "superlative", "sup")
end
end
end
end
Line 346: Line 350:
splitchar = ",",
splitchar = ",",
}
}
if match(lemma, "[aeiouàèìòù]$") then
default_suffix = "th" .. default_suffix
end
if not forms[1] then
if not forms[1] then
forms = {{term = lemma .. default_suffix}}
forms = {{term = lemma .. default_suffix}}
Line 361: Line 370:
insert_inflection(data, forms, label)
insert_inflection(data, forms, label)
end
end
 
-- Included "pres" explicitly for backwards compat. if needed, but retaining past, stative, future.
process_verb_form("pres", (args.type == "b" and "á" or "") .. "ir", "present")
process_verb_form("pres", "ir", "present")
process_verb_form("past", (args.type == "s" and "e" or "") .. "aidhir", "past")
process_verb_form("past", "adhir", "past")
process_verb_form("fut", (args.type == "b" and "á" or "") .. "ist", "future")
process_verb_form("stat", "adhist", "stative")
process_verb_form("cond", (args.type == "s" and "e" or "") .. "aidhist", "conditional")
process_verb_form("fut", "ist", "future")
end
end
end
end
Line 374: Line 382:
["pres"] = {list = true, disallow_holes = true},
["pres"] = {list = true, disallow_holes = true},
["past"] = {list = true, disallow_holes = true},
["past"] = {list = true, disallow_holes = true},
["stat"] = {list = true, disallow_holes = true},
["cond"] = {list = true, disallow_holes = true},
["fut"] = {list = true, disallow_holes = true},
["fut"] = {list = true, disallow_holes = true},
["irr"] = {type = "boolean"},
["irr"] = {type = "boolean"},