Module:Sandbox/Ajuanca/Names: Difference between revisions

Content deleted Content added
Testing
Testing
 
(68 intermediate revisions by the same user not shown)
Line 91:
}},
{ "ru",
{ "Poda", "Petrenko", "Roschin", "Uspensky", "Vladímir"
}},
-- No need to include Wang, Zhang or Chang (common termination -ang).
Line 232:
familyNames = {}
}
if(not(p.isOnlyName(fullNameTable))) then
table.remove(fullNameTable)
local connectors = {"de", "del", "el", "la", "los", "las", "y"}
end
local shouldJoinNext = false
table.insert(name.givenNames, fullNameTable[1])
local prepositions = {"de", "del", "y"}
table.remove(fullNameTable, 1)
for n, name in ipairs(fullNameTable) do
function getPositionOfConecctors(fullNameTable)
for k, connector in ipairs(connectors) do
local connectors = {"de", "del", "y"}
if (name == connector) then
firstSurname = 0
-- Join the surname till there's only one left or
lastSurname = 0
-- there is another preposition.
fullNameTable[n]for =d, fullNameTable[n]actualName ..in ipairs(fullNameTable[n+1])do
for x, connector in ipairs(connectors) do
table.remove(fullNameTable, n+1)
if(connector == actualName) then
shouldJoinNext = true
firstSurname = d
else
for z, lastConnector in ipairs(connectors) do
if(shouldJoinNext and #fullNameTable-1 >= n) then
if((fullNameTable[n#fullNameTable-1] == fullNameTable[n]lastConnector) ..and (firstSurname ~= #fullNameTable[n+-1])) then
lastSurname = #fullNameTable-1
table.remove(fullNameTable, n+1)
return {firstSurname, lastSurname }
for k, preposition in ipairs(prepositions) do
end
if(preposition == fullNameTable[n+1]) then
if(fullNameTable[#fullNameTable-2] == lastConnector and (firstSurname ~= #fullNameTable-2)) then
shouldJoinNext = false
lastSurname = #fullNameTable-2
end
return {firstSurname, lastSurname}
end
end
Line 257 ⟶ 258:
end
end
return { firstSurname, lastSurname }
end
local positions = getPositionOfConecctors(fullNameTable)
-- No doubt last names are family names
if (#fullNameTable >positions[1]= 4=0) then
table.insertif(name.givenNames, #fullNameTable[==1])then
table.insert(name.givenNamesfamilyNames, fullNameTable[21])
table.insertelseif(name.familyNames, #fullNameTable[3]==2)then
-- 1st maybe is a given name
table.insert(name.familyNames, fullNameTable[4])
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, fullNameTable[2])
else
table.insert(name.givenNames, fullNameTable[1])
table.insert(name.familyNames, fullNameTable[2])
table.insert(name.familyNames, fullNameTable[3])
end
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])
end
table.insert(name.familyNames, table.concat(fullNameTable, " ", positions[1], positions[2]-1))
table.insert(name.familyNames, table.concat(fullNameTable, " ", positions[2]))
end
end
return name
Line 397 ⟶ 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