Module:Sandbox/Stibba0/Names Explained

-- Extracting names from names for GCI! :)local dutchSeparation = local chineseSeperation = local arabicSeperation = local spanishSeperation = local spanishLetters = local suffix = local formats =

local divideWords = function(text) wordTable = for word in string.gmatch(text, "%S+") do wordTable[#wordTable+1] = word end for i=1, #suffix do if string.match(wordTable[#wordTable], suffix[i]) then if #wordTable[#wordTable] < 4 then wordTable[#wordTable] = nil end end end return wordTableend

local identifyFormat = function(wordList, fullname) local nameFormat = nil for i=1, #formats do for z=1, #formats[i][2] do for x=1, #wordList do if string.lower(wordList[x])

formats[i][2][z] then if string.lower(wordList[x])

"de" then for b=1, #spanishLetters do if string.match(fullname, spanishLetters[b]) then return end end for b=1, #wordList do if wordList[b][#wordList[b]]

'e' or wordList[b][#wordList[b]]

'a' or wordList[b][#wordList[b]]

'o' or wordList[b][#wordList[b]]

'i' then return end end return else return end end end end end return end

local nameSeparation = function(wordList, lastCount) local names = for i=1, #wordList do if i < lastCount then names["first"] = names["first"] .. " " .. wordList[i] else names["last"] = names["last"] .. " " .. wordList[i] end end return namesend

local formatName = function(wordList, nameFormat, providedFormat) local names = if not(providedFormat

"") then nameFormat[1] = providedFormat end if nameFormat[1]

"nl" or nameFormat[1]

"ar" then names = nameSeparation(wordList, nameFormat[2]) end if nameFormat[1]

"zh" then for i=1, #wordList do if i

1 then names["last"] = wordList[i] else names["first"] = names["first"] .. " " .. wordList[i] end end end if nameFormat[1]

"es" then if not(nameFormat[2]

nil) then if nameFormat[2] > 2 then for i=1, #wordList do if i < (nameFormat[2]-1) then names["first"] = names["first"] .. " " .. wordList[i] else names["last"] = names["last"] .. " " .. wordList[i] end end elseif #wordList > 3 then names = nameSeparation(wordList, nameFormat[2]) end else names = nameSeparation(wordList, #wordList) end end if nameFormat[1]

"std" then names = nameSeparation(wordList, #wordList) end return namesend

local returnNameString = function(names) return "Given = " .. names["first"] .. " -- Family = " .. names["last"]end

local p =

p.getNames = function(frame) local fullname = frame.args.name local provFormat = frame.args.format or "" local wordList = divideWords(fullname) local nameFormat = identifyFormat(wordList, fullname) local names = formatName(wordList, nameFormat, provFormat) local nameString = returnNameString(names) return nameStringend

return p