Module:Disassemble/list

-- local p = {}

local disdata = mw.loadData('Module:Disassemble/data')

function p.main(frame) local args = frame:getParent.args local name = args[1] or '' local catname = name name = string.lower(name):gsub('parts?',''):gsub('components?')

name = mw.text.trim(name)

local list = {} local _listed = {}

for _, v in pairs(disdata) do		local dislist = table.concat(v.often or , v.sometimes or , v.rarely or '',',') dislist = string.lower(dislist) dislist = mw.text.split(dislist,',')

for _, w in ipairs(dislist) do			if w == name then if _listed[w.cat] then -- do nothing else table.insert(list, { v.name, v.cat }) _listed[w.cat] = true end end end end

local ret = {string.format(':Full list: Category:%s',catname)} for _, v in ipairs(list) do		table.insert(ret,string.format('%s',v[2],v[1])) end

return table.concat(ret,'\n') end

return p