Module:zh-verb

विक्षनरी से

"इस मॉड्यूल हेतु प्रलेख Module:zh-verb/doc पर बनाया जा सकता है"

local export = {}

function export.show(frame)
	local args = frame:getParent().args
	local title = args.pagename or mw.title.getCurrentTitle().text
	local inflections = {}
	local sortkey = require('Module:zh-sortkey').makeSortKey(title)

	if args.type then
		local wordtype, div_pos = args.type:match('([a-z]+)([1-9]*)')
		
		local valid_types = {
			['sp'] = 'subject-predicate',
			['vo'] = 'verb-object',
			['vc'] = 'verb-complement',
		}

		wordtype = valid_types[wordtype] or error('Invalid value for parameter "type".')

		div_pos = tonumber(div_pos) or 1
		title = mw.ustring.sub(title, 1, div_pos) .. "⫽" .. mw.ustring.sub(title, div_pos + 1)
		inflections[1] = {label = wordtype}
	end
	return require('Module:headword').full_headword{
		lang = require('Module:languages').getByCode('zh'),
		sc = require('Module:scripts').getByCode('Hani'),
		heads = {title},
		inflections = inflections,
		categories = {'Chinese verbs'},
		sort_key = sortkey
	}
end

return export