Mô đun:eu-headword
Giao diện
- Trang mô đun này thiếu trang con tài liệu. Xin hãy tạo trang tài liệu này.
- Liên kết hữu ích: danh sách trang con • liên kết • nhúng • trường hợp kiểm thử • chỗ thử
local export = {}
local m_string_utilities = require("Module:string utilities")
local m_table = require("Module:table")
local lang = require("Module:languages").getByCode("eu")
local rsplit = m_string_utilities.split
local rfind = m_string_utilities.find
local rsplit = m_string_utilities.split
local rsub = m_string_utilities.gsub
local unpack = unpack or table.unpack -- Lua 5.2 compatibility
--add links to hyphenated terms
local function process_links(word)
if rfind(word, " ") then
return "[[" .. rsub(word, " ", "]] [[") .. "]]"
elseif rfind(word, "%-") then
return "[[" .. rsub(word, "%-", "]]-[[") .. "]]"
end
return word
end
--adjectives and adverbs
function export.show_adj_adv(frame)
local pos = frame.args.pos
if not m_table.listToSet {"Phó từ", "Tính từ"}[pos] then
error("Invalid part of speech: <adverbs> and <adjectives> are the only valid values")
end
local args = frame:getParent().args
local data = {lang = lang, pos_category = pos, categories = {}, sort_key = args.sort, heads = {args.head}, genders = {}, inflections = {}}
local tracking_categories = {}
local stem = mw.title.getCurrentTitle().text
local comparative, superlative, excessive = {}, {}, {}
if stem:sub(-1) == "r" then
stem = stem .. 'r' --add an r if the adjective ends in r
elseif stem:sub(-1) == "a" then
stem = stem:sub(1, -2)
end
if args[1] == "-" then
table.insert(data.categories, pos .. " không so sánh được tiếng Basque")
data.inflections = {{label = "không so sánh được"}}
elseif args[1] == "?" then
table.insert(data.categories, pos .. " nghi vấn tiếng Basque")
table.insert(data.categories, pos .. " không so sánh được tiếng Basque")
data.inflections = {{label = "nghi vấn"}}
elseif args[1] == "#" and pos == "Tính từ" then
table.insert(data.categories, pos .. " không biến cách tiếng Basque")
table.insert(data.categories, pos .. " không so sánh được tiếng Basque")
data.inflections = {{label = "không biến cách"}}
else
if stem == "ongi" then
data.inflections = {{label = "so sánh hơn", "hobeto", "hobeki"}, {label = "so sánh nhất", "hobekien", "ongien"}, {label = "quá mức", "ongiegi"}}
elseif stem == "ondo" then
data.inflections = {{label = "so sánh hơn", "hobeto", "hobeki"}, {label = "so sánh nhất", "ondoen"}, {label = "quá mức", "ondoegi"}}
elseif stem == "asko" then --either the adverb or the adjective
data.inflections = {{label = "so sánh hơn", "gehiago"}, {label = "so sánh nhất", "gehien"}, {label = "quá mức", "gehiegi"}}
elseif stem == "on" then
data.inflections = {{label = "so sánh hơn", "hobe"}, {label = "so sánh nhất", "onen", "hoberen"}, {label = "quá mức", "onegi"}}
else
data.inflections = {{label = "so sánh hơn", accel = {form = "comparative"}, stem .. "ago"}, {label = "so sánh nhất", accel = {form = "superlative"}, stem .. "en"},
{label = "quá mức", accel = {form = "excd"}, stem .. "egi"}}
end
end
return require("Module:headword").full_headword(data) ..
require("Module:utilities").format_categories(tracking_categories, lang, args.sort)
end
--determiners
function export.show_det(frame)
local args = frame:getParent().args
local data = {lang = lang, pos_category = "determiners", categories = {}, sort_key = args.sort, heads = {args.head}, genders = {}, inflections = {}}
local tracking_categories = {}
local stem = mw.title.getCurrentTitle().text
local comparative, superlative, excessive = {}, {}, {}
if args[1] == "b" then
data.inflections = {{label = "đề nghị"}}
elseif args[1] == "a" then
data.inflections = {{label = "trì hoãn"}}
elseif args[1] == "ba" or args[1] == "ab" then
data.inflections = {{label = "đề nghị/trì hoãn"}}
end
if args[2] == "?" then
table.insert(data.categories, "Từ hạn định nghi vấn tiếng Basque")
if args[1] == "b" then
data.inflections = {{label = "đề nghị, nghi vấn"}}
end
elseif args[2] == "dem" then
table.insert(data.categories, "Từ hạn định chỉ định tiếng Basque")
if args[1] == "a" then
data.inflections = {{label = "trì hoãn, chỉ định"}}
end
elseif args[2] == "ind" then
table.insert(data.categories, "Từ hạn định bất định tiếng Basque")
end
return require("Module:headword").full_headword(data) ..
require("Module:utilities").format_categories(tracking_categories, lang, args.sort)
end
--nouns
function export.show_noun(frame)
local args = frame:getParent().args
local g, genders = args.g or args[1]
local data = {lang = lang, pos_category = frame.args.proper and "Danh từ riêng" or "Danh từ", categories = {}, sort_key = args.sort, heads = {args.head}, genders, inflections = {}}
local tracking_categories = {}
if g == "an" then
data.genders = { "an" }
elseif g == "in" then
data.genders = { "in" }
elseif g == "both" then
data.genders = { "in","an" }
else
data.genders = { "?" }
end
if args.head then
data.heads = {args.head}
else
data.heads = {process_links(mw.title.getCurrentTitle().text)}
end
return require("Module:headword").full_headword(data) ..
require("Module:utilities").format_categories(tracking_categories, lang, args.sort)
end
--numerals
function export.show_numeral(frame)
local args = frame:getParent().args
local head_processed = require("Module:headword").add_multiword_links(mw.title.getCurrentTitle().text)
if string.find(head_processed, "geita") then
head_processed = mw.ustring.gsub(head_processed, "geita", "gei]][[eta|ta")
end
local data = {lang = lang, pos_category = "Số từ", categories = {}, sort_key = args.sort, heads = {head_processed}}
local tracking_categories = {}
return require("Module:headword").full_headword(data)
end
--verbs
function export.show_verb(frame)
local args = frame:getParent().args
local data = {lang = lang, pos_category = "Động từ", categories = {}, sort_key = args.sort, heads = {args.head}, genders = {"m"}, inflections = {}, info_mid={}, nogendercat=1} --the gender parameter is a placeholder
local tracking_categories = {}
local stem = mw.title.getCurrentTitle().text
local stem_s = stem
local ending = ""
local fut_part_en = ""
if stem:sub(-2,-1) == "tu" then
stem_s = stem:sub(1, -3)
ending = "tu"
elseif stem:sub(-2,-1) == "du" then
stem_s = stem:sub(1, -3)
ending = "du"
elseif stem:sub(-1) == "l" then
ending = "l"
elseif stem:sub(-1) == "n" then
stem_s = stem:sub(1,-2)
ending = "n"
elseif stem:sub(-1) == "i" then
stem_s = stem:sub(1,-2)
ending = "i"
end
--some verbs ending in -i can have "irregular" short forms (they are predictable, but as there aren't many of them it's easier to enter them manually)
if args.inf or args.short then
stem_s = args.inf or args.short
end
--for verbs ending in -rri
if stem_s:sub(-2,-1) == "rr" then
stem_s = stem_s:sub(1,-2)
end
--generate the non-finite forms
if ending == "du" or ending == "tu" then
fut_part_ko = stem .. "ko"
inf = stem_s
if ('szx'):match(stem_s:sub(-1)) then
v_noun = stem_s .. "te"
else
v_noun = stem_s .. "tze"
end
elseif ending == "n" then
fut_part_ko = stem .. "go"
fut_part_en = stem .. "en"
inf = stem
v_noun = stem_s .. "te"
elseif ending == "l" then
fut_part_ko = stem .. "ko"
fut_part_en = stem .. "en"
inf = stem
v_noun = stem_s .. "tze"
elseif ending == "i" then
fut_part_ko = stem .. "ko"
inf = stem_s
if stem_s:sub(-2,-1) == "tz" then
v_noun = stem_s:sub(1,-3) .. "zte"
elseif stem_s:sub(-2,-1) == "ts" then
v_noun = stem_s:sub(1,-3) .. "ste"
elseif stem_s:sub(-2,-1) == "tx" then
v_noun = stem_s:sub(1,-3) .. "xte"
elseif ('szx'):match(stem_s:sub(-1)) then
v_noun = stem_s .. "te"
else
v_noun = stem_s .. "tze"
end
else
fut_part_ko = stem .. "ko"
inf = stem
v_noun = stem_s .. "tze"
end
--for verbs like "ezagutu", where the short form isn't "ezagu", but "ezagut"
if args.si then
inf = args.si
end
--irregular future participle (for noun+izan verbs where the future participle is noun-ko, not noun+izango) or for verbs ending in -n/-l in which only one ending is used
if args.fi then
fut_part_ko = args.fi
end
-- irregular verbal noun
if args.vn then
v_noun = args.vn
end
--compound verbs
local light_verb
local words = rsplit(stem, " ")
if #words > 1 then
light_verb = words[#words]
table.insert(data.categories, "Động từ ghép tiếng Basque")
table.insert(data.categories, 'Động từ ghép với dạng "' .. light_verb .. ' tiếng Basque"')
end
--transitivity
if args[1] == "da" then
table.insert(data.categories, "Động từ da tiếng Basque")
table.insert(data.info_mid, '<abbr title="nội động từ không có tân ngữ gián tiếp">da</abbr>')
elseif args[1] == "du" then
table.insert(data.categories, "Động từ du tiếng Basque")
table.insert(data.info_mid, '<abbr title="ngoại động từ không có tân ngữ gián tiếp">du</abbr>')
elseif args[1] == "dio" then
table.insert(data.categories, "Động từ dio tiếng Basque")
table.insert(data.info_mid, '<abbr title="ngoại động từ có tân ngữ gián tiếp">dio</abbr>')
elseif args[1] == "zaio" then
table.insert(data.categories, "Động từ zaio tiếng Basque")
table.insert(data.info_mid, '<abbr title="nội động từ có tân ngữ gián tiếp">zaio</abbr>')
elseif args[1] == "da-du" then
table.insert(data.categories, "Động từ da tiếng Basque")
table.insert(data.categories, "Động từ du tiếng Basque")
table.insert(data.info_mid, '<abbr title="ngoại động từ/nội động từ không có tân ngữ gián tiếp">da/du</abbr>')
elseif args[1] == "du-dio" then
table.insert(data.categories, "Động từ du tiếng Basque")
table.insert(data.categories, "Động từ dio tiếng Basque")
table.insert(data.info_mid, '<abbr title="ngoại động từ có hoặc không có tân ngữ gián tiếp">du/dio</abbr>')
elseif args[1] == "du-zaio" then
table.insert(data.categories, "Động từ du tiếng Basque")
table.insert(data.categories, "Động từ zaio tiếng Basque")
table.insert(data.info_mid, '<abbr title="ngoại động từ có tân ngữ trực tiếp/nội động từ có tân ngữ gián tiếp">du/zaio</abbr>')
elseif args[1] == "da-dio" then
table.insert(data.categories, "Động từ da tiếng Basque")
table.insert(data.categories, "Động từ dio tiếng Basque")
table.insert(data.info_mid, '<abbr title="nội động từ hoặc ngoại động từ có tân ngữ trực tiếp">da/dio</abbr>')
elseif args[1] == "da-du-zaio" then
table.insert(data.categories, "Động từ da tiếng Basque")
table.insert(data.categories, "Động từ du tiếng Basque")
table.insert(data.categories, "Động từ zaio tiếng Basque")
table.insert(data.info_mid, '<abbr title="nội động từ/ngoại động từ không có tân ngữ gián tiếp, nội động từ có tân ngữ gián tiếp">da/du/zaio</abbr>')
elseif args[1] == "da-zaio" then
table.insert(data.categories, "Động từ da tiếng Basque")
table.insert(data.categories, "Động từ zaio tiếng Basque")
table.insert(data.info_mid, '<abbr title="nội động từ có hoặc không có tân ngữ gián tiếp">da/zaio</abbr>')
elseif args[1] == "da-du-dio-zaio" then
table.insert(data.categories, "Động từ da tiếng Basque")
table.insert(data.categories, "Động từ du tiếng Basque")
table.insert(data.categories, "Động từ dio tiếng Basque")
table.insert(data.categories, "Động từ zaio tiếng Basque")
table.insert(data.info_mid, '<abbr title="nội động từ/ngoại động từ có hoặc không có tân ngữ gián tiếp">da/du/dio/zaio</abbr>')
else
table.insert(data.categories, "Động từ không chuyển tiếp tiếng Basque")
table.insert(data.info_mid, '<abbr title="không chuyển tiếp">?</abbr>')
end
if (ending == "l" or ending == "n") and (not args.fi) then
data.inflections = {{label = "phân từ chưa hoàn thành", v_noun .. "n"}, {label = "phân từ tương lai", fut_part_ko, fut_part_en}, {label = "dạng ngắn", inf}, {label = "danh động từ", v_noun}}
else
data.inflections = {{label = "phân từ chưa hoàn thành", v_noun .. "n"}, {label = "phân từ tương lai", fut_part_ko}, {label = "dạng ngắn", inf}, {label = "danh động từ", v_noun}}
end
return
require("Module:headword").full_headword(data)
:gsub('<span class="gender">.-</span>', '<i>'..table.concat(data.info_mid, ' ')..'</i>') ..
require("Module:utilities").format_categories(tracking_categories, lang, args.sort)
end
--verb forms
function export.show_verb_form(frame)
local args = frame:getParent().args
local data = {lang = lang, pos_category = "Biến thể hình thái động từ", categories = {}, sort_key = args.sort, heads = {}, genders = {}, inflections = {}}
local tracking_categories = {}
------
local pagename = args.pagename or mw.title.getCurrentTitle().text
data.heads = {pagename}
local m_all, f_all = require("Module:eu-allocutives").generate_allocutive(pagename, nil or args[1])
if m_all then
data.inflections =
{{label = "masculine allocutive", accel = {form = "mall", origin = pagename}, unpack(m_all)}, {label = "feminine allocutive", accel = {form = "fall", origin = pagename}, unpack(f_all)}}
end
return require("Module:headword").full_headword(data) .. require("Module:utilities").format_categories(tracking_categories, lang, args.sort)
end
return export