Module:User:Wyang/simplify-cat

This is a private module sandbox of Wyang, for their own experimentation. Items in this module may be added and removed at Wyang's discretion; do not rely on this module's stability.


local export = {}

local shorten = {
	["nouns"] = "n", ["noun"] = "n", 
	["proper nouns"] = "pn", ["proper noun"] = "pn", ["proper"] = "pn", 
	["pronouns"] = "pron", ["pronoun"] = "pron", 
	["verbs"] = "v", ["verb"] = "v", 
	["adjectives"] = "a", ["adjective"] = "a", ["adj"] = "a", 
	["adverbs"] = "adv", ["adverb"] = "adv", 
	["prepositions"] = "prep", ["preposition"] = "prep", 
	["postpositions"] = "postp", ["postposition"] = "postp", 
	["conjunctions"] = "con", ["conjunction"] = "con", ["conj"] = "con", 
	["particles"] = "part", ["particle"] = "part", 
	["prefixes"] = "pref", ["prefix"] = "pref", 
	["suffixes"] = "suf", ["suffix"] = "suf",
	["proverbs"] = "prov", ["proverb"] = "prov", 
	["idioms"] = "id", ["idiom"] = "id", 
	["chengyu"] = "cy", 
	["phrases"] = "ph", ["phrase"] = "ph", 
	["interjections"] = "intj", ["interjection"] = "intj", ["interj"] = "intj", 
	["classifiers"] = "cls", ["classifier"] = "cls", 
	["numerals"] = "num", ["numeral"] = "num", 
}

function export.make_short(frame)
	local otext = frame.args[1] or nil
	local result = {}
	if otext and otext ~= "" then
		for item in mw.text.gsplit(otext, ",") do
			table.insert(result, shorten[item] or item)
		end
	end
	return table.concat(result, ",")
end

return export