Module:Ancient Greek words with English derivatives

Hello, you have come here looking for the meaning of the word Module:Ancient Greek words with English derivatives. In DICTIOUS you will not only get to know all the dictionary meanings for the word Module:Ancient Greek words with English derivatives, but we will also tell you about its etymology, its characteristics and you will know how to say Module:Ancient Greek words with English derivatives in singular and plural. Everything you need to know about the word Module:Ancient Greek words with English derivatives you have here. The definition of the word Module:Ancient Greek words with English derivatives will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofModule:Ancient Greek words with English derivatives, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.

A user suggests that this Translingual module be moved, merged or split.
Please see the discussion on Requests for moves, mergers and splits(+) for more information and remove this template after the request has been fulfilled.

local export = {}

local function interpret_character_entities(text)
	return text:gsub(
		"&(#?)(x?)(+);",
		function (numeric, hexadecimal, code)
			if numeric == "#" then
				if hexadecimal == "x" then
					return mw.ustring.char(tonumber(code, 16))
				else
					return mw.ustring.char(tonumber(code))
				end
			end
		end)
end

-- U+0304 COMBINING MACRON, U+0306 COMBINING BREVE
local function remove_macron_breve(text)
	return mw.ustring.toNFD(text):gsub("\204", "")
end

-- U+0300 COMBINING GRAVE ACCENT, U+0301 COMBINING ACUTE ACCENT, U+0342 COMBINING GREEK PERISPOMENI
local function remove_accents(text)
	return mw.ustring.toNFD(interpret_character_entities(text)):gsub("\204", ""):gsub("\205\130", "")
end

local function link(text)
	text = interpret_character_entities(text)
	return '<span class="Polyt" lang="grc">[['
		.. remove_macron_breve(text)
		.. '|' .. text .. ']]</span>'
end

local function tag(text)
	return '<span class="Polyt" lang="grc">' .. text .. '</span>'
end

local function form_English_link(entry, alt)
	return "]"
end

local function English_link(text)
	if not text or text == "" then
		return "&mdash;"
	elseif text:find("[[", 1, true) then
		return text:gsub("%]+)|?(.-)%]%]", form_English_link)
	else
		return form_English_link(text)
	end
end

local auto_subtable_mt = {
	__index = function(self, key)
		local val = {}
		self = val
		return val
	end,
}

local function auto_subtable()
	return setmetatable(
		{},
		auto_subtable_mt)
end

local function make_row_table(cells, column_count)
	local trim = mw.text.trim
	local rows = auto_subtable()
	
	local column_number = 0
	local row_number = 1
	for i, cell in ipairs(cells) do
		if column_number == column_count then
			column_number = 1
			row_number = row_number + 1
		else
			column_number = column_number + 1
		end
		
		rows = trim(cell)
	end
	
	-- Remove auto-subtabling.
	setmetatable(rows, nil)
	
	return rows
end

local function print_table(rows)
	local output = {}
	for i, row in ipairs(rows) do
		row = interpret_character_entities(row)
		output = ("|-\n| %s || %s || %s || %s || %s || %s\n")
			:format(link(row), (require("Module:languages").getByCode("grc"):transliterate(row)), tag(remove_accents(row)), row or "", row or "", English_link(row))
	end
	
	table.insert(output, 1, '{| class="wikitable"\n! colspan="2" | Citation form || colspan="2" | Root form || Meaning || English derivative\n')
	table.insert(output, "|}")
	
	return table.concat(output)
end

function export.Greek_derivative_table(frame)
	local args = frame:getParent().args
	return print_table(make_row_table(args, 5))
end

return export