Springe nei ynhâld

Module:th-headword

Ut Wikiwurdboek
De neikommende dokumintaasje stiet op Module:th-headword/dokumintaasje. [bewurkje]

Oernommen fan en:Module:th-headword.

Oerset:

  • foutmelding
  • lebels
  • kategorynammen
  • sykteksten

Oanpast:

  • wurdsoartkoades yn stee fan wurdsoartnammen
  • opsykjen wurdsoartnammen yn data (poscode/poscat)
  • parameters skowe 1 plak op
  • accel útskeakele

Taheakke:

  • alternative wurdsoartkoades

local export = {}
local pos_functions = {}

local lang = require("Module:languages").getByCode("th")
local script = require('Module:scripts').getByCode("Thai")
local PAGENAME = mw.title.getCurrentTitle().text
local pron = require("Module:th-pron")

function export.show(frame)

	local args = frame:getParent().args
	local poscode = frame.args[1] or error("Wurdsoarte is net opjûn. Jou a.j.w. parameter 1 by it oanroppen fan 'e module.")
	
	local lemmas = mw.loadData("Module:headword/data").lemmas
	local nonlemmas = mw.loadData("Module:headword/data").nonlemmas
	local poscat = lemmas[poscode] or nonlemmas[poscode] or error("De wurdsoartkoade \"" .. poscode .. "\" is net jildich.")
	
	local data = {lang = lang, sc = script, pos_category = poscat, categories = {}, heads = {args["head"] or PAGENAME}, inflections = {}}
	
	if args["cat2"] then
		table.insert(data.categories, args["cat2"] .. " yn it Taisk")
	end
	if args["cat3"] then
		table.insert(data.categories, args["cat3"] .. " yn it Taisk")
	end
	
	if pos_functions[poscode] then
		pos_functions[poscode](args, data)
	end
	
	local phon
	local content = mw.title.new(PAGENAME):getContent()
	local code = mw.ustring.match(content, '{{th%-pron[^o}]*}}')
	local false_positive = mw.ustring.match(content, 'note=') or mw.ustring.match(content, 'yn ûnbrûk rekke stavering fan') or mw.ustring.match(content, 'yn ûnbrûk rekke foarm fan') or mw.ustring.match(content, 'alternative stavering fan') or mw.ustring.match(content, 'argayske stavering fan') or mw.ustring.match(PAGENAME, 'Net-stipe')

	if not code then
		phon = args["phon"] or args["mono"] or "-"
		data.translits = {pron.translit(phon , "th", "Thai", "paiboon")}
		if not false_positive then
			table.insert(data.categories, "Termen sûnder th-pron-berjocht yn it Taisk")
		end
	else
		phon = args["phon"] or args["mono"] or mw.ustring.match(code, '|([^|}]+)') or PAGENAME -- detects only first one
		data.translits = {pron.translit(phon, "th", "Thai", "paiboon")}
	end
	
	if mw.ustring.match(PAGENAME, '.-[ก-ฮ](รร)$') or mw.ustring.match(PAGENAME, '.-[ก-ฮ](รร)[^ะ-ฺๅ็-๎].-') then
		if PAGENAME ~= 'วงจรรวม' and PAGENAME ~= 'สรรวง' then
			table.insert(data.categories, "Termen yn it Taisk stavere mei รร")
		end
	end
	
	local letter = true
	local specialLetter = mw.ustring.gmatch(PAGENAME, '.-([ฤฦ]ๅ?).-')
	while true do
		letter = specialLetter()
		if (not letter) then break end
		table.insert(data.categories, "Termen yn it Taisk stavere mei " .. letter)
	end
	local specialLetter2 = mw.ustring.gmatch(PAGENAME, '.-([/%+%-ฃ๊ฅ๋ฆ็ฌฎฏฐฑฒฬฮใๆ…]).-')
	while true do
		letter = specialLetter2()
		if (not letter) then break end
		if letter == "๊" or letter == "๋" or letter == "็" then
			table.insert(data.categories, "Termen yn it Taisk stavere mei ◌" .. letter) -- add dotted circle for above/below marks
		else
			table.insert(data.categories, "Termen yn it Taisk stavere mei " .. letter)
		end
	end
	--"Category:Thai terms spelled with ทร read as ซ" is detected in Module:th-pron

	return require("Module:headword").full_headword(data)

end

pos_functions["subst"] = function(args, data)

	local classifiers = {label = "klassifikator"}

	if args[2] then
		for _,par in ipairs(args) do
			if par == "*" then
				table.insert(classifiers, PAGENAME) -- shorthand
				table.insert(data.categories, "Klassifikators yn it Taisk")
				table.insert(data.categories, "Haadwurden yn it Taisk klassifisearre mei " .. PAGENAME)
			else
				table.insert(classifiers, par)
				table.insert(data.categories, "Haadwurden yn it Taisk klassifisearre mei " .. par)
			end
		end
		table.insert(data.inflections, classifiers)
	end

end

pos_functions["verbum"] = function(args, data)

	local par1 = args[2]; if par1 == "" then par1 = nil end
	local par2 = args[3]; if par2 == "" then par2 = nil end
	local par3 = args[4]; if par3 == "" then par3 = nil end
	-- 'accel' n.f.t. (sjoch https://en.wiktionary.org/w/index.php?title=Wiktionary:ACCEL) - PiefPafPier
	--local abstract_forms = {label = "abstract noun", accel = {form = "abstract-noun"}}
	local abstract_forms = {label = "abstrakt haadwurd"}

	if par1 ~= "-" then
		if not par1 then
			table.insert(abstract_forms, "การ" .. PAGENAME)
		else
			if par1 == "~" then
				table.insert(abstract_forms, "การ" .. PAGENAME)
				table.insert(abstract_forms, "ความ" .. PAGENAME)
			else
				table.insert(abstract_forms, par1)
				table.insert(abstract_forms, par2)
				table.insert(abstract_forms, par3)
			end
		end
		table.insert(data.inflections, abstract_forms)
	end

end

pos_functions["adjek"] = function(args, data)

	local par1 = args[2]; if par1 == "" then par1 = nil end
	local par2 = args[3]; if par2 == "" then par2 = nil end
	local par3 = args[4]; if par3 == "" then par3 = nil end
	-- 'accel' n.f.t. - PiefPafPier
	--local abstract_forms = {label = "abstract noun", accel = {form = "abstract-noun"}}
	local abstract_forms = {label = "abstrakt haadwurd"}

	if par1 ~= "-" then
		if not par1 then
			table.insert(abstract_forms, "ความ" .. PAGENAME)
		else
			table.insert(abstract_forms, par1)
			table.insert(abstract_forms, par2)
			table.insert(abstract_forms, par3)
		end
		table.insert(data.inflections, abstract_forms)
	end

end
pos_functions["adjec"] = pos_functions["adjek"]

-- same logic
pos_functions["adverb"] = pos_functions["adjek"]
-- same logic
pos_functions["namme"] = pos_functions["subst"]
pos_functions["nomen"] = pos_functions["subst"]

return export