This is a private module sandbox of Dixtosa, for his own experimentation. Items in this module may be added and removed at Dixtosa's discretion; do not rely on this module's stability.


local export = {}

local m_links = require("Module:links")

local English = {"[[I]]", "[[you]]", "[[he]]", "[[we]]", "[[you ]]", "[[they]]", "[[this]]", "[[that]]", "[[here]]", "[[there]]", "[[who]]", "[[what]]", "[[where]]", "[[when]]", "[[how]]", "[[not]]", "[[all]]", "[[many]]", "[[some]]", "[[few]]", "[[other]]", "[[one]]", "[[two]]", "[[three]]", "[[four]]", "[[five]]", "[[big]]", "[[long]]", "[[wide]]", "[[thick]]", "[[heavy]]", "[[small]]", "[[short]]", "[[narrow]]", "[[thin]]", "[[woman]]", "[[man]]", "[[man]]", "[[child]]", "[[wife]]", "[[husband]]", "[[mother]]", "[[father]]", "[[animal]]", "[[fish]]", "[[bird]]", "[[dog]]", "[[louse]]", "[[snake]]", "[[worm]]", "[[tree]]", "[[forest]]", "[[stick]]", "[[fruit]]", "[[seed]]", "[[leaf]]", "[[root]]", "[[bark ]]", "[[flower]]", "[[grass]]", "[[rope]]", "[[skin]]", "[[meat]]", "[[blood]]", "[[bone]]", "[[fat ]]", "[[egg]]", "[[horn]]", "[[tail]]", "[[feather]]", "[[hair]]", "[[head]]", "[[ear]]", "[[eye]]", "[[nose]]", "[[mouth]]", "[[tooth]]", "[[tongue ]]", "[[fingernail]]", "[[foot]]", "[[leg]]", "[[knee]]", "[[hand]]", "[[wing]]", "[[belly]]", "[[guts]]", "[[neck]]", "[[back]]", "[[breast]]", "[[heart]]", "[[liver]]", "to [[drink]]", "to [[eat]]", "to [[bite]]", "to [[suck]]", "to [[spit]]", "to [[vomit]]", "to [[blow]]", "to [[breathe]]", "to [[laugh]]", "to [[see]]", "to [[hear]]", "to [[know]]", "to [[think]]", "to [[smell]]", "to [[fear]]", "to [[sleep]]", "to [[live]]", "to [[die]]", "to [[kill]]", "to [[fight]]", "to [[hunt]]", "to [[hit]]", "to [[cut]]", "to [[split]]", "to [[stab]]", "to [[scratch]]", "to [[dig]]", "to [[swim]]", "to [[fly]]", "to [[walk]]", "to [[come]]", "to [[lie ]]", "to [[sit]]", "to [[stand]]", "to [[turn]]", "to [[fall]]", "to [[give]]", "to [[hold]]", "to [[squeeze]]", "to [[rub]]", "to [[wash]]", "to [[wipe]]", "to [[pull]]", "to [[push]]", "to [[throw]]", "to [[tie]]", "to [[sew]]", "to [[count]]", "to [[say]]", "to [[sing]]", "to [[play]]", "to [[float]]", "to [[flow]]", "to [[freeze]]", "to [[swell]]", "[[sun]]", "[[moon]]", "[[star]]", "[[water]]", "[[rain]]", "[[river]]", "[[lake]]", "[[sea]]", "[[salt]]", "[[stone]]", "[[sand]]", "[[dust]]", "[[earth]]", "[[cloud]]", "[[fog]]", "[[sky]]", "[[wind]]", "[[snow]]", "[[ice]]", "[[smoke]]", "[[fire]]", "[[ash]]", "to [[burn]]", "[[road]]", "[[mountain]]", "[[red]]", "[[green]]", "[[yellow]]", "[[white]]", "[[black]]", "[[night]]", "[[day]]", "[[year]]", "[[warm]]", "[[cold]]", "[[full]]", "[[new]]", "[[old]]", "[[good]]", "[[bad]]", "[[rotten]]", "[[dirty]]", "[[straight]]", "[[round]]", "[[sharp ]]", "[[dull ]]", "[[smooth]]", "[[wet]]", "[[dry]]", "[[correct]]", "[[near]]", "[[far]]", "[[right]]", "[[left]]", "[[at]]", "[[in]]", "[[with]]", "[[and]]", "[[if]]", "[[because]]", "[[name]]"}
--array - list of 207 objects in this form {gloss=term}
local data = {}

function export.show(frame)
	local args = frame:getParent().args
	local lang = require("Module:languages").getByCode(args[1])
	data = mw.loadData("Module:User:Dixtosa/Swadesh/data/" .. args[1])
	local needsTransliteration = false
	
	local Id = 1
	local table = mw.html.create("table"):addClass("wikitable")
	
	local headers = table:tag("tr")
	for _, text in ipairs { "Id", "English (gloss)", lang:getCategoryName(), "IPA" } do
		headers:tag("th"):node(text)
	end
	
	local makeIPA
	if args[1] == "ka" then
		local IPATranscribe = require("Module:ka-IPA").IPA_transcribe
		function makeIPA(text)
			return '<span class="IPA">' .. IPATranscribe(text) .. '</span>'
		end
	end
	
	for index, value in pairs(data) do
		local row = mw.html.create("tr")
		row:tag("td"):node(Id)
		
		local Englishs = ""
		local Translations = ""
		local IPAs = ""
		for gloss, termData in pairs(value) do
			Englishs = Englishs .. "\n" .. English[Id]
			if gloss ~= "1" then
				 Englishs = Englishs .. " (" .. gloss .. ")"
			end
			
			Translations = Translations .. "\n" .. m_links.full_link({lang = lang, term = termData.term, tr = termData.tr})
			
			if makeIPA then
				IPAs = IPAs .. "\n"
					.. termData.term:gsub("%[%[([^%]]+)%]%]", makeIPA) -- IPA-ify the contents of links
						:gsub(" '*%([^%)]+%)'*", "") -- remove parentheses
			else
				IPAs = IPAs .. "\n" .. (termData.IPA or "")
			end
		end
		
		row:tag("td"):node(Englishs)
		row:tag("td"):node(Translations)
		row:tag("td"):node(IPAs)
		
		table:node(row)
		Id = Id + 1
	end
	
	
	return table;
end

return export