Module:PData

local getArgs = require('Module:Arguments').getArgs

local p = {}

local function makeInvokeFunc(funcName) return function (frame) local args = getArgs(frame) return p[funcName](args) end end

function p.replace(inp, li) --Input, list (of search terms) inp = string.lower(inp) --Make input lowercase for term, r in pairs(li) do --term = search term, r = replacement term inp = string.gsub(inp, term, r)	end return inp end

function p._main(args) if args[1] then str = args[1] str = string.lower(str) --list of search terms and their replacements --"." and "-" have % to escape them when passed to gsub local search = { [" "] = "",			["'"] = "",			[":"] = "",			["%."] = "",			["%-"] = "",			["♂"] = "m", ["♀"] = "f", ["é"] = "e" }		local form = { ["alola?n?"] = "a", --"a" and "n" are optional so it matches "alola" or "alolan" ["galari?a?n?"] = "g" -- See above }		str = p.replace(str, search)

--form name must come after the other --replacements because lua sucks str = p.replace(str, form)

return str end end

p.ND = makeInvokeFunc('_ND') function p._ND(args) local data = mw.loadData("Module:PData/ND") name = p._main({args[1]}) return data[name] or "000" end

p.ND2 = makeInvokeFunc('_ND2') function p._ND2(args) local data = mw.loadData("Module:PData/ND2") name = p._main({args[1]}) return data[name] or "000" end

p.PN = makeInvokeFunc('_PN') function p._PN(args) local data = mw.loadData("Module:PData/PN") name = p._main({args[1]}) return data[name] or "???" end

p.PNum = makeInvokeFunc('_PNum') function p._PNum(args) local data = mw.loadData("Module:PData/PNum") if args[1] then num = args[1] local search = { ["%-"] = "",			["%.png"] = "" }

num = p.replace(num, search) return data[num] or "???" end end

return p