Module:txg

local codepoint = require("Module:string utilities").codepoint local loadData = mw.loadData

local export = {}

local function format_Tangut_text(text) return ' ' .. text .. ' ' end

function export.pron(frame) local args = frame:getParent.args local title = args["1"] or mw.title.getCurrentTitle.text local prons = { loadData("Module:txg/data/LFW2008"), loadData("Module:txg/data/Miyake"), loadData("Module:txg/data/Kychanov2006"), loadData("Module:txg/data/Sofronov1968"), loadData("Module:txg/data/Nishida1966") }	local pron = {{}, {}, {}, {}, {}} local sources = { "Li Fanwen 2008", "Miyake 2019", "Kychanov 2006", "Sofronov 1968", "Nishida 1966" }	local text = {''} for char in title:gmatch("[%z\1-\127\194-\244][\128-\191]*") do		if char ~= "-" then for i = 1, 5 do				table.insert(pron[i], prons[i][char] or "?") end end end for i = 1, 5 do		for _, v in ipairs(pron[i]) do if v ~= "?" then table.insert(text, "\n* (''" .. sources[i] .. "'') : ")				table.insert(text, "*" .. table.concat(pron[i], " ")) break end end end table.insert(text, " ") return table.concat(text) end

function export.newDer(frame) local title = mw.title.getCurrentTitle.subpageText if 101119 > codepoint(title) and codepoint(title) >= 100352 then idslist = require("Module:txg/data/idslist").list else wordlist = require("Module:txg/data/wordlist").list end local args = frame:getParent.args local result = {} for _, arg in ipairs(args) do		table.insert(result, arg) end if wordlist then for _, word in ipairs(wordlist) do			if word:match(title) and word ~= title then table.insert(result, word) end end elseif idslist then for char, seq in pairs(idslist) do			if seq:match(title) and seq ~= title then table.insert(result, char) end end end return "" end

function export.see(frame) local params = { [1] = {},	}	local args = require("Module:parameters").process(frame:getParent.args, params) local title = args[1] local curr_title = mw.title.getCurrentTitle.subpageText local content = mw.title.new(title):getContent local senses = {} local sense_id = 0 local j, pos, s, section if title == curr_title then return error("The soft-directed item is the same as the page title.") end if content then if not content:match("==Tangut==") then categories = categories .. ""		elseif not content:match("txg%-pron") and not content:match("txg%-see") then require("Module:debug").track("txg-see/unidirectional reference to variant") elseif not content:match(curr_title) then require("Module:debug").track("txg-see/unidirectional reference variant→orthodox") end end while true do		_, j, language_name, s = content:find("%f[=]==%s*([^=]+)%s*==(\n.-)\n==%f[^=]", pos) if j == nil then i, j, language_name, s = content:find("%f[=]==%s*([^=]+)%s*==(\n.+)", pos) end if j == nil then break else pos = j - 1 end if language_name == "Tangut" then section = s		end end if not section then return "" end section = section:gsub("\n===+Etymology.-(\n==)", "%1") section = section:gsub("\n===+Glyph origin.-(\n==)", "%1") local text = {''} table.insert(text, 'This character is a variant form of ' .. frame:expandTemplate{ title = "l", args = { "txg", title} } .. " ") for sense in section:gmatch("\n# ([^\n]+)") do		if not sense:match("rfdef") and not sense:match("defn") then sense_id = sense_id + 1 table.insert(senses, sense) end end if sense_id == 0 then table.insert(text, ".") else table.insert(text, ":\n# " .. table.concat(senses, "\n# ")) end table.insert(text, " ") return frame:preprocess( table.concat(text) ) end

return export