「モジュール:sh-headword」の版間の差分
ナビゲーションに移動
検索に移動
削除された内容 追加された内容
Alexandr3126 (トーク | 投稿記録) 細編集の要約なし |
Alexandr3126 (トーク | 投稿記録) basic_no_gender |
||
53行目: | 53行目: | ||
end |
end |
||
⚫ | |||
-- [[テンプレート:sh-verb-form]]用 |
|||
⚫ | |||
local params = { |
|||
["head"] = {list = true, default = ""}, |
|||
["tr"] = {list = true, allow_holes = true}, |
|||
} |
|||
local args = require("モジュール:parameters").process(frame:getParent().args, params) |
|||
local data = {lang = lang, pos_category = frame.args[1], categories = {}, heads = args["head"], genders = args["g"], inflections = {}} |
|||
otherscript(data.inflections, args) |
|||
return require("モジュール:headword").full_headword(data) |
|||
end |
|||
-- [[テンプレート:sh-adverb]] |
|||
function export.basic_adverb(frame) |
|||
local params = { |
local params = { |
||
["head"] = {list = true, default = ""}, |
["head"] = {list = true, default = ""}, |
2022年1月17日 (月) 17:13時点における版
このモジュールについての説明文ページを モジュール:sh-headword/doc に作成できます
local export = {}
local lang = require("モジュール:languages").getByCode("sh")
local function otherscript(inflections, args)
local title = mw.title.getCurrentTitle()
local sc = require("モジュール:scripts").findBestScript(title.subpageText, lang)
local other_sc
if sc:getCode() == "Latn" then
other_sc = "Cyrl"
elseif sc:getCode() == "Cyrl" then
other_sc = "Latn"
end
other_sc = require("モジュール:scripts").getByCode(other_sc)
local inflection = {label = other_sc:getCanonicalName() .. ""}
for i, head in ipairs(args["head"]) do
if head == "" then
head = title.subpageText
end
local tr = args["tr"][i]
if not tr then
tr = require("モジュール:sh-translit").tr(require("モジュール:links").remove_links(head), "sh", sc:getCode())
end
table.insert(inflection, {term = tr, sc = other_sc})
end
table.insert(inflections, inflection)
end
function export.basic(frame)
local params = {
["g"] = {list = true, default = "?"},
["head"] = {list = true, default = ""},
["tr"] = {list = true, allow_holes = true},
}
local args = require("モジュール:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = frame.args[1], categories = {}, heads = args["head"], genders = args["g"], inflections = {}}
otherscript(data.inflections, args)
return require("モジュール:headword").full_headword(data)
end
function export.basic_no_gender(frame)
local params = {
["head"] = {list = true, default = ""},
["tr"] = {list = true, allow_holes = true},
}
local args = require("モジュール:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = frame.args[1], categories = {}, heads = args["head"], genders = args["g"], inflections = {}}
otherscript(data.inflections, args)
return require("モジュール:headword").full_headword(data)
end
function export.adjective(frame)
local params = {
["comp"] = {},
["def"] = {},
["head"] = {list = true, default = ""},
["tr"] = {list = true, allow_holes = true},
}
local args = require("モジュール:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = "形容詞", categories = {}, heads = args["head"], genders = {}, inflections = {}}
if args["def"] then
table.insert(data.inflections, {label = "限定", args["def"]})
end
if args["comp"] then
table.insert(data.inflections, {label = "比較級", args["comp"]})
end
otherscript(data.inflections, args)
return require("モジュール:headword").full_headword(data)
end
local gender_cats = {
["m"] = "男性",
["f"] = "女性",
["n"] = "中性",
["m-p"] = "男性",
["f-p"] = "女性",
["n-p"] = "中性",
}
function export.noun(frame)
local params = {
["g"] = {list = true, default = "?"},
["head"] = {list = true, default = ""},
["tr"] = {list = true, allow_holes = true},
["m"] = {list = true},
["f"] = {list = true},
}
local args = require("モジュール:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = "名詞", categories = {}, heads = args["head"], genders = args["g"], inflections = {}}
for i, gender in ipairs(data.genders) do
if gender_cats[gender] then
table.insert(data.categories, lang:getCanonicalName() .. " " .. gender_cats[gender] .. "名詞")
else
data.genders[i] = "?"
end
end
otherscript(data.inflections, args)
-- Add feminine and masculine forms.
for _, val in pairs { { "f", "feminine" }, { "m", "masculine" }} do
local param_name, label = unpack(val)
local forms = args[param_name]
if forms[1] then
forms.label = label
table.insert(data.inflections, forms)
end
end
return require("モジュール:headword").full_headword(data)
end
function export.propernoun(frame)
local params = {
["g"] = {list = true, default = "?"},
["head"] = {list = true, default = ""},
["tr"] = {list = true, allow_holes = true},
}
local args = require("モジュール:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = "固有名詞", categories = {}, heads = args["head"], genders = args["g"], inflections = {}}
for i, gender in ipairs(data.genders) do
if gender_cats[gender] then
table.insert(data.categories, lang:getCanonicalName() .. " " .. gender_cats[gender] .. "名詞")
else
data.genders[i] = "?"
end
end
otherscript(data.inflections, args)
return require("モジュール:headword").full_headword(data)
end
function export.verb(frame)
local params = {
["a"] = {},
["head"] = {list = true, default = ""},
["tr"] = {list = true, allow_holes = true},
}
local args = require("モジュール:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = "動詞", categories = {}, heads = args["head"], genders = {}, inflections = {}}
if args["a"] == "impf" or args["a"] == "pf" then
table.insert(data.genders, args["a"])
elseif args["a"] == "impf-pf" or args["a"] == "pf-impf" or args["a"] == "dual" or args["a"] == "ip" then
table.insert(data.genders, "impf")
table.insert(data.genders, "pf")
else
table.insert(data.genders, "?")
end
otherscript(data.inflections, args)
return require("モジュール:headword").full_headword(data)
end
return export