-
-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add surnames from several languages, and correct
Netherland/Flemish, Icelandic, Polish, Turkish, Danish, Romanian, Greek, English ...and update & correct Italian names
- Loading branch information
Showing
26 changed files
with
5,096 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
-- Copyright © 2008-2022 Pioneer Developers. See AUTHORS.txt for details | ||
-- Licensed under the terms of the GPL v3. See licenses/GPL-3.txt | ||
|
||
local utils = require 'utils' | ||
|
||
local CultureName = { | ||
male = {}, -- List of 100 most common male first names | ||
female = {}, -- List of 100 most common female first names | ||
surname = {}, -- List of 100 most common last names | ||
name = "Name", -- Name of language / culture | ||
code = "xx", -- ISO ISO 639-1 language code | ||
replace = {} -- Non-ascii char to replacement char -table | ||
} | ||
|
||
CultureName.__index = CultureName | ||
|
||
function CultureName.New (self) | ||
self = setmetatable(self or {}, CultureName) | ||
|
||
-- Populate self.surname_ascii | ||
self.surname_ascii = self:AsciiReplace(self.surname) | ||
|
||
return self | ||
end | ||
|
||
-- Generate an ASCII-replaced name table from the given input data and the | ||
-- culture's character replacement data. | ||
function CultureName:AsciiReplace(nametable) | ||
-- if replacement table empty, names are assumed to be already ascii | ||
if next(nametable) == nil then return end | ||
|
||
-- else, loop over all names and replacement chars | ||
local ascii = {} | ||
for _, name in ipairs(nametable) do | ||
-- print("Replacing name", name) | ||
for old, new in pairs(self.replace) do | ||
name = name:gsub(old, new) | ||
end | ||
table.insert(ascii, name) | ||
end | ||
|
||
return ascii | ||
end | ||
|
||
function CultureName:FirstName (isFemale, rand) | ||
local array = isFemale and self.female or self.male | ||
return utils.chooseEqual(array, rand) | ||
end | ||
|
||
-- Some cultures have gender specific surnames | ||
function CultureName:Surname (isFemale, rand, ascii) | ||
local surname = ascii and self.surname_ascii or self.surname | ||
-- if ascii then print(#surname, surname == self.surname_ascii) end | ||
return utils.chooseEqual(surname, rand) | ||
end | ||
|
||
function CultureName:FullName (isFemale, rand) | ||
return self:FirstName(isFemale, rand) .. " " .. self:Surname(isFemale, rand) | ||
end | ||
|
||
return CultureName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
-- Copyright © 2008-2022 Pioneer Developers. See AUTHORS.txt for details | ||
-- Licensed under the terms of the GPL v3. See licenses/GPL-3.txt | ||
|
||
-- give name, first and last name functions | ||
|
||
local utils = require 'utils' | ||
|
||
local de = require '.de' -- german | ||
local da = require '.da' -- danish | ||
local es = require '.es' -- spanish | ||
local en = require '.en' -- english | ||
local fi = require '.fi' -- finish | ||
local fr = require '.fr' -- french | ||
local gd = require '.gd' -- gaelic | ||
local el = require '.el' -- greek | ||
local hu = require '.hu' -- hungarian | ||
local is = require '.is' -- islandic | ||
local it = require '.it' -- italian | ||
local ja = require '.ja' -- japanese | ||
local nl = require '.nl' -- netherlands | ||
local nb = require '.nb' -- norwegian bokmål | ||
local pl = require '.pl' -- polish | ||
local ro = require '.ro' -- romanian | ||
local ru = require '.ru' -- russian | ||
local sv = require '.sv' -- swedish | ||
local us = require '.us' -- USA | ||
local tr = require '.tr' -- turkish | ||
local zh = require '.zh' -- chinese/mandarin | ||
local misc = require '.misc' -- Our old namegen / developer's names | ||
|
||
-- | ||
-- Class: Culture | ||
-- | ||
|
||
local Culture = {} | ||
|
||
Culture.weights = { | ||
{lang = da, weight = 1.0}, | ||
{lang = de, weight = 3.0}, | ||
{lang = el, weight = 1.0}, | ||
{lang = en, weight = 6.0}, | ||
{lang = es, weight = 3.0}, | ||
{lang = fi, weight = 1.0}, | ||
{lang = fr, weight = 3.0}, | ||
{lang = gd, weight = 0.5}, | ||
{lang = hu, weight = 1.0}, | ||
{lang = is, weight = 0.5}, | ||
{lang = it, weight = 3.0}, | ||
{lang = ja, weight = 3.0}, | ||
{lang = nb, weight = 1.0}, | ||
{lang = nl, weight = 2.0}, | ||
{lang = pl, weight = 1.0}, | ||
{lang = ro, weight = 1.0}, | ||
{lang = ru, weight = 3.0}, | ||
{lang = sv, weight = 1.0}, | ||
{lang = tr, weight = 1.0}, | ||
{lang = us, weight = 5.0}, | ||
{lang = zh, weight = 3.0}, | ||
{lang = misc, weight = 5.0}, | ||
} | ||
|
||
-- Normalize weights to sum to 1 | ||
utils.normWeights(Culture.weights) | ||
|
||
-- Map language string to module table | ||
Culture.lookup = {} | ||
print("Random generated names from:") | ||
for k, v in pairs(Culture.weights) do | ||
Culture.lookup[v.lang.name] = v.lang | ||
print("* ", k, v.lang.code, v.lang.name, v.lang, v.weight) | ||
end | ||
|
||
-- | ||
-- Function: FirstName | ||
-- | ||
-- Create first name, from specified culture, or default to weighted | ||
-- probability from pre-set list of available cultures. See parameter | ||
-- and return documentation from Culture:FullName() | ||
-- | ||
-- > name = Culture:FirstName(isfemale, rand, culture) | ||
-- | ||
function Culture:FirstName (isFemale, rand, culture) | ||
local c = self.lookup[culture] or utils.chooseNormalized(self.weights, rand).lang | ||
return c:FirstName(isFemale) | ||
end | ||
|
||
-- | ||
-- Function: Surname | ||
-- | ||
-- Create surname, from specified culture, or default to weighted | ||
-- probability from pre-set list of available cultures. See parameter | ||
-- and return documentation from Culture:FullName(). | ||
-- | ||
-- > name = Culture:Surname(isfemale, rand, culture, make_ascii) | ||
-- | ||
function Culture:Surname (isFemale, rand, culture, ascii) | ||
local c = self.lookup[culture] or utils.chooseNormalized(self.weights, rand).lang | ||
return c:Surname(isFemale, rand, ascii) | ||
end | ||
|
||
|
||
-- | ||
-- Function: FullName | ||
-- | ||
-- Create a full name, where first and last match the same | ||
-- language/culture. If no culture is specified, one is randomly | ||
-- selected according to pre-set weights. Valid input is one of the | ||
-- following (capitalized) strings: | ||
-- | ||
-- Danish German Greek English Spanish Finish French Gaelic Hungarian | ||
-- Icelandic Italian Japanese Norwegian Dutch Polish Russian Swedish | ||
-- Turkish Chinese | ||
-- | ||
-- > name = Culture:FullName(isfemale, rand, culture) | ||
-- | ||
-- Parameters: | ||
-- | ||
-- isfemale - whether to generate a male or female name. true for female, | ||
-- false for male | ||
-- | ||
-- rand - the <Rand> object to use to generate the name | ||
-- | ||
-- culture - optional string | ||
-- | ||
-- Return: | ||
-- | ||
-- name - a string containing matching first and last name | ||
-- | ||
-- Return full name from the same culture/language | ||
function Culture:FullName (isFemale, rand, culture) | ||
-- if 'culture' given as a string, e.g. "Russian" use that | ||
local c = self.lookup[culture] or utils.chooseNormalized(self.weights, rand).lang | ||
|
||
-- local debug_code = "(".. c.code .. ") " | ||
-- return debug_code .. c:FullName(isFemale, rand) | ||
return c:FullName(isFemale) | ||
end | ||
|
||
|
||
return Culture |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
-- Copyright © 2008-2022 Pioneer Developers. See AUTHORS.txt for details | ||
-- Licensed under the terms of the GPL v3. See licenses/GPL-3.txt | ||
|
||
-- https://www.dst.dk/da/Statistik/emner/befolkning-og-valg/navne/navne-i-hele-befolkningen | ||
|
||
local CultureName = require './common' | ||
|
||
local male = { | ||
"Peter", | ||
"Michael", | ||
"Jens", | ||
"Lars", | ||
"Thomas", | ||
"Henrik", | ||
"Søren", | ||
"Christian", | ||
"Jan", | ||
"Martin", | ||
"Niels", | ||
"Anders", | ||
"Morten", | ||
"Jesper", | ||
"Mads", | ||
"Rasmus", | ||
"Hans", | ||
"Per", | ||
"Jørgen", | ||
"Ole" | ||
} | ||
|
||
local female = { | ||
"Anne", | ||
"Kirsten", | ||
"Mette", | ||
"Hanne", | ||
"Helle", | ||
"Anna", | ||
"Susanne", | ||
"Lene", | ||
"Maria", | ||
"Marianne", | ||
"Lone", | ||
"Camilla", | ||
"Pia", | ||
"Louise", | ||
"Charlotte", | ||
"Tina", | ||
"Gitte", | ||
"Bente", | ||
"Jette", | ||
"Karen" | ||
} | ||
|
||
local surname = { | ||
"Nielsen", | ||
"Jensen", | ||
"Hansen", | ||
"Andersen", | ||
"Pedersen", | ||
"Christensen", | ||
"Larsen", | ||
"Sørensen", | ||
"Rasmussen", | ||
"Jørgensen", | ||
"Petersen", | ||
"Madsen", | ||
"Kristensen", | ||
"Olsen", | ||
"Thomsen", | ||
"Christiansen", | ||
"Poulsen", | ||
"Johansen", | ||
"Møller", | ||
"Mortensen" | ||
} | ||
|
||
local Danish = CultureName.New({ | ||
male = male, | ||
female = female, | ||
surname = surname, | ||
name = "Danish", | ||
code = "da", | ||
replace = { | ||
["æ"] = "a", ["Æ"] = "A", | ||
["ø"] = "o", ["Ø"] = "O", | ||
["å"] = "aa", ["Å"] = "Aa", | ||
} | ||
}) | ||
|
||
return Danish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.