Module:Sandbox/Ajuanca/Names: Difference between revisions

Content deleted Content added
Testing
Testing
 
(45 intermediate revisions by the same user not shown)
Line 232:
familyNames = {}
}
if(not(p.isOnlyName(fullNameTable))) then
table.remove(fullNameTable)
end
local connectors = {"de", "del", "y"}
local firstSurname = 0
local lastSurname = 0
table.insert(name.givenNames, fullNameTable[1])
table.remove(fullNameTable, 1)
forfunction d, actualName in ipairsgetPositionOfConecctors(fullNameTable)do
local connectors = {"de", "del", "y"}
for x, connector in ipairs(connectors) do
firstSurname = 0
if(connector == actualName) then
firstSurnamelastSurname = d0
for zd, lastConnectoractualName in ipairs(connectorsfullNameTable) do
for x, connector in ipairs(connectors) do
if(fullNameTable[#fullNameTable-1] == lastConnector and (firstSurname ~= #fullNameTable-1)) then
if(connector == actualName) then
lastSurname = #fullNameTable-1
endfirstSurname = d
for z, lastConnector in ipairs(connectors) do
if((fullNameTable[#fullNameTable-21] == lastConnector) and (firstSurname ~= #fullNameTable-21)) then
lastSurname = #fullNameTable-21
return {firstSurname, lastSurname }
end
if(fullNameTable[#fullNameTable-2] == lastConnector and (firstSurname ~= #fullNameTable-2)) then
lastSurname = #fullNameTable-2
return {firstSurname, lastSurname}
end
end
end
end
end
if(return { firstSurname~=0), lastSurname then}
end
if(lastSurname~=0)then
local positions = getPositionOfConecctors(fullNameTable)
table.insert(name.familyNames, table.concat(fullNameTable, " ", firstSurname, lastSurname))
if(positions[1]==0) then
table.insert(name.familyNames, table.concat(fullNameTable, " ", lastSurname+1))
if(#fullNameTable==1)then
return name
table.insert(name.familyNames, fullNameTable[1])
elseif(#fullNameTable==2)then
-- 1st maybe is a given name
local isGiven = true
local terminations = {"ez", "es", "is", "iz"}
for c, termination in ipairs(terminations) do
local finalLetters = string.sub(fullNameTable[1], -2, -1)
if (finalLetters == termination) then
isGiven = false
end
end
if(isGiven)then
table.insert(name.givenNames, fullNameTable[1])
else
table.insert(name.familyNames, table.concat(fullNameTable, " "..#fullNameTable, firstSurname)[1])
return name
end
table.insert(name.familyNames, fullNameTable[2])
else
iftable.insert(#name.givenNames, fullNameTable==[1]) then
table.insert(name.familyNames, fullnameTablefullNameTable[12])
table.insert(name.familyNames, fullNameTable[3])
return
elseend
else
if(positions[2]==0)then
if(positions[1]==1) then
-- Maybe a second surname is behind
table.insert(name.familyNames, table.concat(fullNameTable, " ", positions[1]))
elseif(positions[1]==2)then
-- 1st maybe is a given name
local isGiven = true
local terminations = {"ez", "es", "is", "iz"}
for c, termination in ipairs(terminations) do
local finalLetters = string.sub(fullNameTable[1], -2, -1)
if (finalLetters == termination) then
isGiven = false
end
end
if(isGiven)then
table.insert(name.givenNames, fullNameTable[1])
else
table.insert(name.familyNames, fullNameTable[1])
end
table.insert(name.familyNames, table.concat(fullNameTable, " ", positions[1]))
end
else
if(positions[1]==2)then
table.insert(name.givenNames, fullNameTable[1])
table.insert(name.familyNames, fullNameTable[2])
return name
end
table.insert(name.familyNames, table.concat(fullNameTable, " ", positions[1], positions[2]-1))
table.insert(name.familyNames, table.concat(fullNameTable, " ", positions[2]))
end
end
-- No doubt last names are family names
--if (#fullNameTable >= 4) then
-- table.insert(name.givenNames, fullNameTable[1])
-- table.insert(name.givenNames, fullNameTable[2])
-- table.insert(name.familyNames, fullNameTable[3])
-- table.insert(name.familyNames, fullNameTable[4])
--end
return name
end
Line 413 ⟶ 447:
end
return isJustName
end
 
function p.test(frame)
name = tostring(frame.args.name)
local str = "no working"
-- First step is compare possible know surnames that exit the normal form or cause conflicts with other
-- indicators.
local commonSurnames = {
{ "es",
{ "Navarro", "Gil", "Serrano", "Sanz", "Ortega", "Iglesias", "Cruz", "Aguilar",
"Rivera", "Herrera", "Castro", "Luna", "Garza", "Soto", "Diaz"
}},
{ "de",
{ "Mies"
}},
{ "ru",
{ "Poda", "Petrenko", "Roschin", "Uspensky"
}},
-- No need to include Wang, Zhang or Chang (common termination -ang).
{ "zh",
{ "Wáng", "Wāng", "Li", "Lei", "Lie", "Lee", "Cheung", "Chen", "Zhou", "Zhao"
}}
}
-- Search for a common surname that scapes from previous rules.
for d, specificLanguageTable in ipairs(commonSurnames) do
for x, surname in ipairs(specificLanguageTable[2]) do
if(surname == name) then
return specificLanguageTable[1]
end
end
end
return str
end
return p