Module:qhv-noun/head

From Linguifex
Jump to navigation Jump to search


local export = {}

local m_p = require("Module:qhv-noun")
local m_d = require("Module:qhv-noun/data")
local PAGENAME = mw.title.getCurrentTitle().text

function export.generate(frame)
	local case = frame.args[1]
	local word = frame.args[2] == nil and nil or PAGENAME
	local data = {forms = {}, categories = {}}
	local decl, stem = m_p.detect_decl(word)
	
	stem = {table.concat(stem), "a"}
	
	if m_d[word] then m_d[word](stem, data)
	else m_d[decl](stem, data) end
	
	if tostring(mw.getCurrentFrame():preprocess('function')):find('<strong class="error"') then --iferror
    	return "?"
    end
	
	return table.concat(data.forms[case], ",")
end

function export.pass_to_module(case, term, reanalyzed)
	local word = term or PAGENAME
	local data = {forms = {}, categories = {}}
	local decl, stem = m_p.detect_decl(word, reanalyzed)
	
	stem = {table.concat(stem), "a"}
	
	if m_d[word] then m_d[word](stem, data)
	else m_d[decl](stem, data) end
	
	return table.concat(data.forms[case], ",")
end

return export