Modül:th

Merhaba, buraya Modül:th kelimesinin anlamını aramaya geldiniz. DICTIOUS'da Modül:th kelimesinin tüm sözlük anlamlarını bulmakla kalmayacak, aynı zamanda etimolojisini, özelliklerini ve Modül:th kelimesinin tekil ve çoğul olarak nasıl söylendiğini de öğreneceksiniz. Modül:th kelimesi hakkında bilmeniz gereken her şey burada. Modül:th kelimesinin tanımı, konuşurken veya metinlerinizi yazarken daha kesin ve doğru olmanıza yardımcı olacaktır. XXX'in ve diğer kelimelerin tanımını bilmek, kelime dağarcığınızı zenginleştirir ve size daha fazla ve daha iyi dilsel kaynaklar sağlar.
Modül belgelemesi


local export = {}
local gsub = mw.ustring.gsub
local sub = mw.ustring.sub
local m_translit = require("Modül:th-alfabeçeviri")

function export.new(frame)
	local title = mw.title.getCurrentTitle().text
	local args = frame:getParent().args
	local phonSpell = args or title
	local pos = args or ""
	local def = args or "{{rfdef|lang=th}}"
	local pos2 = args or (args and "" or false)
	local def2 = args or "{{rfdef|lang=th}}"
	local pos3 = args or (args and "" or false)
	local def3 = args or "{{rfdef|lang=th}}"
	local etym = args or false
	local head = args or false
	local cls = args or false
	
	local result = ""
	
	local function genTitle(text)
		local pos_title = {
			 = "Noun",  = "Noun",  = "Proper noun",  = "Proper noun",  = "Pronoun",
			 = "Verb",  = "Adjective",  = "Adjective",  = "Adverb",
			 = "Preposition",  = "Postposition",  = "Conjunction",
			 = "Particle",  = "Suffix",
			 = "Proverb",  = "Idiom",  = "Phrase",  = "Interjection",  = "Interjection",
			 = "Classifier",  = "Classifier",  = "Numeral",  = "Abbreviation",  = "Determiner"
		};
		return pos_title or mw.ustring.upper(sub(text, 1, 1)) .. sub(text, 2, -1)
	end
	
	local function genHead(text)
		local pos_head = {
			 = "noun",  = "noun",  = "proper noun",  = "proper noun",  = "verb",  = "adj",
			 = "post",  = "con",  = "particle",  = "pronoun",
			 = "proverb",  = "idiom",  = "phrase",  = "interj",
			 = "abbr",  = "cls",  = "det"
		};
		return pos_head or text
	end
	
	local function other(class, title, args)
		local code = ""
		if args then
			code = code .. "\n\n===" .. title .. "===\n{{th-" .. class .. "|" .. args
			i = 2
			while args do
				code = code .. "|" .. args
				i = i + 1
			end
			code = code .. "}}"
		end
		return code
	end
	
	result = result .. "==Thai=="
	if args then result = result .. "\n{{wikipedia|lang=th}}" end
	result = result .. other("alt", "Alternative forms", args)
	
	if etym then result = result .. "\n\n===Etymology===\n" .. etym end
	
	result = result .. "\n\n===Pronunciation===\n{{th-pron" .. ((phonSpell ~= title and phonSpell ~= "") and ("|" .. gsub(phonSpell, ",", "|")) or "") .. "}}"
	result = result .. "\n\n===" .. genTitle(pos) .. "===\n{{th-" .. genHead(pos) .. ((cls and genHead(pos) == "noun") and "|" .. cls or "") .. (head and ("|head=" .. head) or "") .. "}}\n\n# " .. def
	
	result = result .. other("syn", "=Synonyms=", args)
	result = result .. other("ant", "=Antonyms=", args)
	result = result .. other("der", "=Derived terms=", args)
	result = result .. other("also", "=See also=", args)
	
	if pos2 then
		result = result .. "\n\n===" .. genTitle(pos2) .. "===\n{{th-" .. genHead(pos2) .. ((cls and genHead(pos2) == "noun") and "|" .. cls or "") .. (head and ("|head=" .. head) or "") .. "}}\n\n# " .. def2
	end
	
	if pos3 then
		result = result .. "\n\n===" .. genTitle(pos3) .. "===\n{{th-" .. genHead(pos3) .. ((cls and genHead(pos2) == "noun") and "|" .. cls or "") .. (head and ("|head=" .. head) or "") .. "}}\n\n# " .. def3
	end
	
	return result
end

function export.getTranslit(lemmas, phonSpell)
	local m_th_pron = require("Modül:th-söyleniş")
	if not phonSpell then
		phonSpell = lemmas
		for lemma in mw.ustring.gmatch(lemmas, "+") do
			if mw.title.new(lemma).exists then
				content = mw.title.new(lemma):getContent()
				template = mw.ustring.match(content, "{{th%-pron*}}")
				if template ~= "" then
					lemma = mw.ustring.gsub(lemma, "%-", "%" .. "-")
					template = mw.ustring.match(content, "{{th%-pron|(+)}}")
					phonSpell = mw.ustring.gsub(phonSpell, lemma, template and mw.text.split(template, "|") or lemma)
				end
			end
		end
	end
	transcription = m_th_pron.translit(phonSpell, "th", "Thai", "paiboon", "translit-module")
	transcription = transcription or nil
	return transcription
end
	
function export.link(frame)
	local args = frame:getParent().args
	local lemma = args or error("Page to be linked to has not been specified. Please pass parameter 1 to the module invocation.")
	local phonSpell = args or false
	local gloss = args or args or ""
	local transcription = export.getTranslit(lemma, phonSpell)
	return frame:expandTemplate{ title = "l", args = {"th", lemma, nil, gloss = gloss, sc = "Thai", tr = transcription}}
end

function export.usex(frame)
	local args = frame:getParent().args
	local pagename = mw.title.getCurrentTitle().text
	local text = {}
	local example = args or error("Example has not been specified. Please pass parameter 1 to the module invocation.")
	local translation = args or ""
	local exSet, romSet = {}, {}
	
	boldify = example ~= pagename and true or false
	example = gsub(example, "%*", pagename) -- shorthand
	example = gsub(example, "ฯ  ", "ฯ ")
	example = gsub(example, "  ", "&")
	example = gsub(example, "(+)", " %1 ")
	example = gsub(example, " +", " ")
	example = gsub(example, "^ ", "")
	example = gsub(example, " $", "")
	example = gsub(example, "(+)(*)ๆ", function(previous, space)
		return previous .. (space == "" and " " or space) .. previous .. "ๆ" end)
	
	local syllables = mw.text.split(example, " ", true)
	
	for index, thaiWord in ipairs(syllables) do
		local phonSpell, content, template = "", "", ""
		if mw.ustring.match(thaiWord, "") then
			phonSpell = thaiWord
			if mw.ustring.match(thaiWord, "ๆ$") then
				phonSpell = sub(phonSpell, 1, -2)
				thaiWord = "ๆ"
			end
			if mw.ustring.match(thaiWord, "") then
				phonSpell = mw.ustring.match(phonSpell, "{(+)}")
				thaiWord = mw.ustring.match(thaiWord, "^+")
			else
				if thaiWord ~= "ๆ" and mw.title.new(thaiWord).exists then
					content = mw.title.new(thaiWord):getContent()
					template = mw.ustring.match(content, "{{th%-pron*}}")
					if template ~= "" then
						template = mw.ustring.match(content, "{{th%-pron|(+)}}")
						phonSpell = template and mw.text.split(template, "|") or thaiWord
					else
						phonSpell = thaiWord
					end
				end
			end
			table.insert(exSet, "]")
			if thaiWord == pagename and boldify then
				thaiWord = "<b>" .. thaiWord .. "</b>"
				phonSpell = "<b>" .. phonSpell .. "</b>"
			end
			local transcript = m_translit.tr(phonSpell, "th", "Thai")
			if not transcript then
				require("Modül:debug").track("th-x/unsuccessful romanisation")
			end
			table.insert(romSet, transcript)
		else
			table.insert(exSet, thaiWord)
			table.insert(romSet, m_translit.tr(thaiWord, "th", "Thai"))
		end
	end
	
	example = table.concat(exSet)
	example = gsub(example, " ", "")
	example = gsub(example, "&", " ")
	example = gsub(example, "ฯ", "ฯ ")
	example = gsub(example, "()(%%])", "%1 %2")
	example = gsub(example, "(%%])()", "%1 %2")
	
	translit = table.concat(romSet, " ")
	translit = gsub(translit, " & ", ", ")
	translit = gsub(translit, "&", " ")
	translit = gsub(translit, " :", ":")
	translit = gsub(translit, "%( ", "(")
	translit = gsub(translit, " %)", ")")
	
	if translation == "" then
		table.insert(text, '<span lang="th" class="Thai">' .. example .. '</span> (<i>' .. translit .. '</i>)</span>')
	else
		table.insert(text, ('<span lang="th" class="Thai">%s</span>'):format(example))
		--if mw.ustring.match(example, "") or mw.ustring.len(example) > 50 then
			table.insert(text, "<dl><dd>''" .. translit .. "''</dd><dd>" .. translation .. "</dd></dl>")
		--else
		--	table.insert(text, "&nbsp; ―&nbsp; ''" .. translit .. "''&nbsp; ―&nbsp; " .. translation)
		--end
	end
	return table.concat(text)
end

function export.derived(frame, other_types)
	local obsolete_note = '<sup><span class="explain" title="Archaic, obsolete or dated.">†</span></sup>'
	local m_columns = require("Modül:sütunlar")
	local lang = require("Modül:diller").getirKodaGore("th")
	local m_baglantilar = require("Modül:bağlantılar")
	local args = frame:getParent().args
	local pagename = mw.title.getCurrentTitle().text
	local result = {}
	local length = 0
	
	unfold = args and true or false
	title = args or false
	title_text = title or other_types or "Derived terms"

	if args then
		return '<div class="pseudo NavFrame" ><div class="NavHead" style="text-align:left">' .. title_text ..
			' <span style="font-weight: normal" >— <i>see</i></span > ' .. m_baglantilar.tam_bag({ dil = lang, sozcuk = args }) .. '</div></div>'
	end

	for i, word in ipairs(args) do
		word, is_obsolete = gsub(word, "†", "")
		obsolete = is_obsolete > 0 and obsolete_note or ""
		local word_parts = mw.text.split(gsub(word, "\n", "" ), ":")
		table.insert(result, obsolete .. 
			m_baglantilar.tam_bag({ dil = lang, sozcuk = word_parts, anlam = word_parts or nil }))
		
		length = math.max(mw.ustring.len(word), length)
	end
	
	return 
		m_columns.create_table(
			(length > 15 and 2 or 3), 
			result, 
			1, 
			"#F5F5FF",
			((unfold or #result < 7) and false or true), 
			"Derived terms",
			title_text, 
			math.floor(80 / 3), 
			"* ",
			lang
		)
end

function export.synonym(frame)
	return export.derived(frame, "Synonyms")
end

function export.antonym(frame)
	return export.derived(frame, "Antonyms")
end

function export.also(frame)
	return export.derived(frame, "See also")
end

function export.alternative(frame)
	return export.derived(frame, "Alternative forms")
end

function export.related(frame)
	return export.derived(frame, "Related terms")
end

return export