Jump to content

Module:also/auto

Wiktionary වෙතින්

This module page is experimental.
The details of its operation have not yet been fully decided upon. Do not deploy widely until the module page is finished.

local p = {}

local PAGENAME = mw.title.getCurrentTitle().text
local m_unicode = require("Module:Unicode data")
local m_data = require("Module:also/processed data") -- this contains only existing pages

function get_hashkey(word)
	buffer = mw.ustring.toNFKD(mw.ustring.lower(word))
	for k, v in pairs(m_data.customkeys) do
		buffer = mw.ustring.gsub(buffer, k, v)
	end
	hashkey = {}
	for cp in mw.ustring.gcodepoint(buffer) do
		table.insert(hashkey, is_valid(cp) and mw.ustring.char(cp) or "")
	end
	return table.concat(hashkey)
end

function is_valid(cp)
	category = m_unicode.lookup_category(cp)
	return (category:match("^[LN].$") or category == "Mc") -- can't rely on built-in %w class
end

function p.main(frame)
	local hashkey = get_hashkey(PAGENAME)
	local data = m_data.lookups[hashkey] or {}
	for i, v in ipairs(frame:getParent().args) do -- if it has manual params
		table.insert(data, v)
	end

	if #data == 0 then
		error("This term does not exist in 'Module:also/processed data' and no parameter is given.")
	end

	local new_frame = frame:newChild{title = frame:getTitle(), args = data}
	function new_frame:getParent()
		return self
	end
	return require('Module:also').main(new_frame)
end

return p
"https://si.wiktionary.org/w/index.php?title=Module:also/auto&oldid=167067" වෙතින් සම්ප්‍රවේශනය කෙරිණි