Module:Sandbox/Redlead07/Names

local p = {}
	
local function dutch(frame)
	local name = frame.args.name or ""
	local given_name = string.match(name, "(%w+)") or ""
	local a = string.match(name, "%w+ (%w+ %w+ %w+)") or 
	string.match(name, "%w+ (%w+ %w+)") or 
	string.match(name, "%w+ (%w+)") or ""
	local family_name = a
	return "Given name = "..given_name.." -- Family name = "..family_name.."<br>"
end

local function english(frame)
	local name = frame.args.name or ""
	local given_name = string.match(name, "(%w+ %w+)") or ""
	local family_name = string.match(name, "%w+ (%w+-%w+)") or 
	string.match(name, "%w+ %w+ (%w+)") or ""
	local suffix = string.match(name, "Jr") or string.match(name, "Sr") or ""
	local suffix2 = string.match(name, "I") or string.match(name, "II") or 
	string.match(name, "III") or string.match(name, "IV") or 
	string.match(name, "V") or string.match(name, "VI") or 
	string.match(name, "VII") or string.match(name, "VIII") or ""
	if family_name == string.match(name, "%w+ (%w+-%w+)") then 
	given_name = string.match(name, "(%w+)")
	end
	if suffix ~= "" then
	family_name = string.match(name, "%w+ (%w+)") or ""
	given_name = string.match(name, "(%w+) %w+") or ""
	end
	if suffix2 ~= "" then
	family_name = string.match(name, "%w+ %w+ (%u%l+)") or ""
	given_name =  string.match(name, "(%w+ %w+) %u%l+") or ""
	end
	return "Given name = "..given_name.." -- Family name = "..family_name.."<br>"
end
	
local function french(frame)
	local name = frame.args.name or ""
	local given_name = string.match(name, "(%w+-%w+) %w+") or 
	string.match(name, "(%w+) %w+") or ""
	local family_name = string.match(name, "%w+ (%w+-%w+)") or
	string.match(name, "%w+ (%w+)") or ""
	local particles = string.match(name, "%w+ de") or string.match(name, "Du") or 
	string.match(name, "de la") or string.match(name, "Dele") or 
	string.match(name, "Del") or ""
	if particles ~= "" then
	family_name = string.match(name, "%w+ (%w+ %w'%w+)") or 
	string.match(name, "%w+ (%w+ %w+%W+%w+)") or 
	string.match(name, "%w+ (%w+ %w+)") or ""
	family_name = family_name:gsub("^%l", string.upper)
	end
	return "Given name = "..given_name.." -- Family name = "..family_name.."<br>"
end

local function spanish(frame)
	local name = frame.args.name or ""
	local a = string.match(name, "(%w+%W+%w+) %w+") or ""
	local b = string.match(name, "(%w+) %w+") or ""
	local c = string.match(name, "(%W+%w+) %w+") or ""
	local d = string.match(name, "%w+ (%w+%W+%w+)") or ""
	local e = string.match(name, "%w+ %w+(%W+%w+)") or ""
	local f = string.match(name, "%w+(%W+%w+) %w+") or ""
	local family_name = string.match(name, "%w+ (%w+%W+%w+-%w+%W+%w+)") or 
	string.match(name, "%w+ (%w+%W+%w+ %w+ %w+ %w+)") or
	string.match(name, "%w+ (%w+%W+%w+ %w+)") or
	string.match(name, "%w+ (%w+ %w+%W+%w+)") or ""
	local particles = string.match(name, "del") or "" 
	local particles2 = string.match(name, "de la") or ""
	local given_name = ""
	if b ~= "" then given_name = b end
	if a ~= "" and a ~= d then given_name = a end 
	if c ~= "" and c ~= e and c ~= d and c ~= f then given_name = c end
	if particles ~= "" then
	family_name =	string.match(name, "%w+ (%w+ %w+ %w+)") or ""
	family_name = family_name:gsub("^%l", string.upper)
	given_name = string.match(name, "(%w+) %w+") or ""
	end
	if particles2 ~= "" then
	family_name = string.match(name, "%w+ (%w+ %w+ %w+ %w+)") or ""
	family_name = family_name:gsub("^%l", string.upper)
	given_name = string.match(name, "(%w+) %w+") or ""
	end	
	return "Given name = "..given_name.." -- Family name = "..family_name.."<br>"
end

local function chinese(frame)
	local name = frame.args.name or ""
	local a = string.match(name, "%w+ (%w+)") or ""
	local given_name = string.match(name, "%w+ (%w+-%w+)") or  
	string.match(name, "%w+ %w+ (%w+-%w+)") or 
	string.match(name, "%w+ (%w+)") or ""
	local family_name = ""
	local surname = string.match(name, "Lau") or string.match(name, "Lin") or
	string.match(name, "Zhao") or string.match(name, "Liu") or
	string.match(name, "Xu") or string.match(name, "Chow")
	if surname ~= "" then family_name = surname end
	if surname ~= "" and surname == a then 
	family_name = surname 
	given_name = string.match(name, "(%w+) %w+")
	end
	return "Given name = "..given_name.." -- Family name = "..family_name.."<br>"
end
	
function p.test(frame)
	local name, format = frame.args.name or "", frame.args.format or ""
	local a = string.match(name, "(%w+) (%w+) (%w+)") or ""
	local b = string.match(name, "(%W+%w+) (%w+%W+%w+) (%w+)") or 
	string.match(name, "(%w+%W+%w+) (%w+) (%w+%W+%w+)") or
	string.match(name, "(%w+) (%w+%W+%w+) (%w+)") or ""
	local surname = string.match(name, "Lau") or string.match(name, "Lin") or
	string.match(name, "Zhao") or string.match(name, "Liu") or
	string.match(name, "Xu") or string.match(name, "Chow") or ""
	local particles = string.match(name, "del") or string.match(name, "de la") or ""
	local particles2 = string.match(name, "%w+ de") or string.match(name, "Du") or 
	string.match(name, "de la") or string.match(name, "Dele") or 
	string.match(name, "Del") or ""
	local particle = string.match(name, "%w+ de%w+") or ""
	local particles3 = string.match(name, "van der") or string.match(name, "van den") or 
	string.match(name, "van") or string.match(name, "La") or ""
	local suffix = string.match(name, "I") or string.match(name, "II") or 
	string.match(name, "III") or ""
	local txt = ""
	if suffix == "" and (particles ~= "" or b ~= "") then format = spanish end
	if particles2 ~= "" and particle == "" and format == "" then format = french end
	if particles3 ~= "" then format = dutch end
	if surname ~= "" then format = chinese end
	if format == dutch or format == "nl" then txt = dutch(frame) end
	if format == spanish or format == "es" then txt = spanish(frame) end
	if format == french or format == "fr" then txt = french(frame) end
	if format == chinese then txt = chinese(frame) end
	if format == "" and a ~= "" then txt = english(frame) end
	if format == "" and surname == "" and a == "" then
	family_name = string.match(name, "%w+ (%w+-%w+)") or 
	string.match(name, "%w+ (%w+%W+%w+-%w+%W+%w+)") or
	string.match(name, "%w+-%w+ (%w+)") or string.match(name, "%w+ (%w+)") or ""
	given_name = string.match(name, "(%w+-%w+) %w+") or 
	string.match(name, "(%w+) %w+%W+%w+") or string.match(name, "(%w+) %w+-%w+") 
	or string.match(name, "(%w+) %w+") or ""
	txt = "Given name = "..given_name.." -- Family name = "..family_name.."<br>"
	end
	return txt
end	

return p

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.