Module:qhv-noun/head

From Linguifex
< Module:qhv-noun
Revision as of 17:20, 18 March 2021 by Sware (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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