Modul:it-bosh
Bu modul uchun Modul:it-bosh/doc nomli hujjat sahifasini yaratishingiz mumkin
-- This module contains code for Italian headword templates.
-- Templates covered are it-adj and it-noun.
-- See Module:itconj for Italian conjugation templates.
local export = {}
local tili = require("Module:tili").getByCode("it")
function export.itadj(frame)
local params = {
[1] = {},
[2] = {},
[3] = {},
[4] = {},
[5] = {},
["bosh"] = {},
["sort"] = {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {heads = {args["bosh"]}, genders = {}, inflections = {}, categories = {tili:getCanonicalName() .. " sifat soʻzlar"}}
local stem = args[1]
local end1 = args[2]
if not stem then -- all specified
data.heads = args[2]
data.genders = {"m"}
data.inflections = {
{label = "birlik nazokatli", args[3]},
{label = "erkaksiz koʻplik", args[4]},
{label = "nazokatli koʻplik", args[5]}
}
elseif not end1 then -- no ending vowel parameters - generate default
data.genders = {"m"}
data.inflections = {
{label = "birlik nazokatli", stem .. "a"},
{label = "erkaksiz koʻplik", make_plural(stem .. "o","m")},
{label = "nazokatli koʻplik", make_plural(stem .. "a","f")}
}
else
local end2 = args[3] or error("Either 0, 2 or 4 vowel endings should be supplied!")
local end3 = args[4]
if not end3 then -- 2 ending vowel parameters - m and f are identical
data.genders = {"m", "f"}
data.inflections = {
{label = "erkaksiz va nazokatli koʻplik", stem .. end2}
}
else -- 4 ending vowel parameters - specify exactly
local end4 = args[5] or error("Either 0, 2 or 4 vowel endings should be supplied!")
data.genders = {"m"}
data.inflections = {
{label = "birlik nazokatli", stem .. end2},
{label = "erkaksiz koʻplik", stem .. end3},
{label = "nazokatli koʻplik", stem .. end4}
}
end
end
return require("Module:headword").full_headword(tili, nil, data.heads, nil, data.genders, data.inflections, data.categories, args["sort"])
end
function export.itnoun(frame)
PAGENAME = mw.title.getCurrentTitle().text
local params = {
[1] = {},
[2] = {},
["f"] = {},
["bosh"] = {},
["m"] = {},
["sort"] = {},
}
local args = require("Module:parameters").process(frame:getParent().args, params)
local data = {heads = {args["bosh"]}, genders = {}, inflections = {}, categories = {tili:getCanonicalName() .. " ot soʻzlar"}}
-- Jinsi
if args[1] == "mf" then
data.genders = {"m", "f"}
else
data.genders = {args[1]}
end
if #data.genders == 0 then
data.genders = {"?"}
end
-- Plural
local plural = args[2]
if not plural then
plural = make_plural(PAGENAME, data.genders[1])
end
if plural == "-" then
table.insert(data.inflections, {label = "doimiy"})
else
table.insert(data.inflections, {label = "koʻplik", plural})
end
-- Boshqa jinsi
if args["f"] then
table.insert(data.inflections, {label = "jenskiy rod", args["f"]})
end
if args["m"] then
table.insert(data.inflections, {label = "erkak", args["m"]})
end
-- Turkum
if (data.heads[1] or PAGENAME):find('o$') and data.genders[1] == "f" then
table.insert(data.categories, "Tartibsizlik jinsi bilan Italiya so'zlar")
end
if (data.heads[1] or PAGENAME):find('a$') and data.genders[1] == "m" then
table.insert(data.categories, "Tartibsizlik jinsi bilan italiyan so'zlar")
end
return require("Module:headword").full_headword(tili, nil, data.heads, nil, data.genders, data.inflections, data.categories, args["sort"])
end
-- Generate a default plural form, which is correct for most regular nouns
function make_plural(word, gender)
-- If there are spaces in the term, then we can't reliably form the plural.
-- Return nothing instead.
if word:find(" ") then
return nil
elseif word:find("io$") then
word = word:gsub("io$", "i")
elseif word:find("ologo$") then
word = word:gsub("o$", "i")
elseif word:find("[cg]o$") then
word = word:gsub("o$", "hi")
elseif word:find("o$") then
word = word:gsub("o$", "i")
elseif word:find("[cg]a$") then
word = word:gsub("a$", (gender == "m" and "hi" or "he"))
elseif word:find("[cg]ia$") then
word = word:gsub("ia$", "e")
elseif word:find("a$") then
word = word:gsub("a$", (gender == "m" and "i" or "e"))
elseif word:find("e$") then
word = word:gsub("e$", "i")
end
return word
end
-- Generate a default feminine form
function make_feminine(word, gender)
if word:find("o$") then
return word:gsub("o$", "a")
else
return word
end
end
return export