Mô đun:ug-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_com = require("Mô đun:ug-common")
local pos_functions = {}
local lang = require("Mô đun:languages").getByCode("ug")
local PAGENAME = mw.title.getCurrentTitle().text
local prefix_categories = {
["Tính từ"] = true,
["Phó từ"] = true,
["Danh từ"] = true,
["Động từ"] = true,
}
local function track(page)
require("Mô đun:debug").track("ug-headword/" .. page)
return true
end
function export.make_plural_noun(singular, vv, change)
local base, v, c = m_com.getLast(singular)
if not v then return nil end
if change == "yes" then
if vv ~= nil and vv ~= "" then
v = vv
else
if c == "" and (v == "ا" or v == "ە") then
v = "ى"
end
end
end
local term = base .. v .. c
local tongue = m_com.checkTongue(singular)
if tongue == "front" then
return term .. "لەر"
elseif tongue == "back" then
return term .. "لار"
else
-- [[Special:WhatLinksHere/Template:tracking/ug-headword/central vowels]]
track("central vowels")
end
return nil
end
-- The main entry point.
-- This is the only function that can be invoked from a template.
function export.show(frame)
local poscat = frame.args[1] or error("Part of speech has not been specified. Please pass parameter 1 to the module invocation.")
local params = {
["head"] = {list = true},
["suff"] = {type = "boolean"},
}
if mw.ustring.find(PAGENAME, " ") then
-- [[Special:WhatLinksHere/Template:tracking/ug-headword/space]]
track("space")
end
if pos_functions[poscat] then
for key, val in pairs(pos_functions[poscat].params) do
params[key] = val
end
end
local args = require("Mô đun:parameters").process(frame:getParent().args, params)
local data = {lang = lang, pos_category = poscat, categories = {}, heads = args["head"], genders = {}, inflections = {enable_auto_translit = true}, categories = {}}
if args["suff"] then
data.pos_category = "suffixes"
if suffix_categories[poscat] then
local singular_poscat = poscat:gsub("s$", "")
table.insert(data.categories, lang:getCanonicalName() .. " " .. singular_poscat .. "-forming suffixes")
else
error("No category exists for suffixes forming " .. poscat .. ".")
end
end
if pos_functions[poscat] then
pos_functions[poscat].func(args, data)
end
return require("Mô đun:headword").full_headword(data)
end
-- Display additional inflection information for a noun
pos_functions["Danh từ"] = {
params = {
[1] = {}, -- Vowel, if there is a change
["pl"] = {}, --plural override
["change"] = {}, -- yes or (else:no)
},
func = function(args, data)
local pl = args["pl"] or nil
local change = args["change"] or "yes"
if pl == "-" then
table.insert(data.inflections, {label = "[[Phụ lục:Từ điển thuật ngữ#Không đếm được|không đếm được]]"})
table.insert(data.categories, "Danh từ tiếng Duy Ngô Nhĩ không đếm được")
else
table.insert(data.categories, "Danh từ tiếng Duy Ngô Nhĩ đếm được")
if not pl then
local plural = export.make_plural_noun(PAGENAME, args[1], change)
if plural then
pl = plural
else
table.insert(data.categories, "Uyghur nouns with unpredictable plurals")
end
end
if pl then
local infl = {label = 'số nhiều', {term=pl}}
table.insert(data.inflections, infl)
-- else
-- table.insert(data.categories, "Uyghur nouns needing plural inflection")
end
end
if pl and not mw.title.new(pl).exists then
table.insert(data.categories, "Danh từ tiếng Duy Ngô Nhĩ có liên kết đỏ trong dòng tiêu đề")
end
end
}
pos_functions["proper nouns"] = {
params = {
[1] = {}, -- Vowel, if there is a change
["pl"] = {}, --plural override
["change"] = {}, -- yes or (else:no)
},
func = function(args, data)
local pl = args["pl"] or nil
local change = args["change"] or "yes"
if pl == "-" then
table.insert(data.inflections, {label = "[[Phụ lục:Từ điển thuật ngữ#Không đếm được|không đếm được]]"})
table.insert(data.categories, "Danh từ riêng tiếng Duy Ngô Nhĩ không đếm được")
else
table.insert(data.categories, "Danh từ riêng tiếng Duy Ngô Nhĩ đếm được")
if not pl then
local plural = export.make_plural_noun(PAGENAME, args[1], change)
if plural then
pl = plural
else
table.insert(data.categories, "Uyghur proper nouns with unpredictable plurals")
end
end
if pl then
local infl = {label = 'plural', {term=pl}}
table.insert(data.inflections, infl)
-- else
-- table.insert(data.categories, "Uyghur nouns needing plural inflection")
end
end
if pl and not mw.title.new(pl).exists then
table.insert(data.categories, "Danh từ riêng tiếng Duy Ngô Nhĩ có liên kết đỏ trong dòng tiêu đề")
end
end
}
function export.noun(frame)
local params = {
[1] = {}, -- Vowel, if there is a change
["pl"] = {}, --plural override
["head"] = {},
["change"] = {}, -- yes or (else:no)
}
local args = require("Mô đun:parameters").process(frame:getParent().args, params)
local data = {
lang = lang,
pos_category = "nouns",
categories = {},
heads = {args["head"]},
inflections = {enable_auto_translit = true}
}
local pl = args["pl"] or nil
local change = args["change"] or "yes"
if pl == "-" then
table.insert(data.inflections, {label = "[[Phụ lục:Từ điển thuật ngữ#Không đếm được|không đếm được]]"})
table.insert(data.categories, "Danh từ tiếng Duy Ngô Nhĩ không đếm được")
else
if not pl then
local plural = export.make_plural_noun(PAGENAME, args[1], change)
if plural then
pl = plural
else
table.insert(data.categories, "Uyghur nouns with unpredictable plurals")
end
end
if pl then
local infl = {label = 'impersonal nominative plural', {term=pl}}
table.insert(data.inflections, infl)
-- else
-- table.insert(data.categories, "Uyghur nouns needing plural inflection")
end
end
if pl and not mw.title.new(pl).exists then
table.insert(data.categories, "Danh từ tiếng Duy Ngô Nhĩ có liên kết đỏ trong dòng tiêu đề")
end
return require("Mô đun:headword").full_headword(data)
end
return export