Modulo:AutoDescriptionHuman
Dokumentado por ĉi tiu modulo povas esti kreata ĉe Modulo:AutoDescriptionHuman/dokumentado
--[[
------------------------------------------
-- AutoDescriptionHuman
-- Модуль для заполнения людей.
------------------------------------------
--]]
local Dates = require("Modulo:Dates")
local Declension = require("Modulo:Declension")
local Langs = require("Modulo:Langs")
local MathTonumber = require("Modulo:Math/tonumber")
local ReturnGendered = require("Modulo:ReturnGendered")
local SerializeTable = require("Modulo:SerializeTable")
local Math = require("Modulo:Math")
local AutoDescriptionHuman={}
-- Нам необходимо сформировать и вернуть три переменных
local description = "" -- уточнение (то, что в скобочках после имени, например, на языке оригинала, годы жизни и т.п.)
local details = "" -- строка описания
local categories = "[[Kategorio:Personoj laŭ alfabeto]]" -- категории
-- Промежуточный масив сущностей, в который помещаются результаты парсинга перед формированием описания
local entitiesArray = {P21 = "", P27 = "", P39 = "", P69 = "", P101 = {}, P101Q ="", P108 = "", P108Q = "",
P136="", P166="", P184="", P185="", P463 = {}, P463Q = "", P509 = "", P512 = "", P551="", P569 = "",
P570 = "", P734 = "", P735 = "", P737Q = "", P800="", P802="", P937="", P1066="", P1196="", P1303="", P1344="",
P3373="", erdosNumber = "", male = "", female = "", langName="", nativeName="",
placeOfBirth="", countryOfBirth="", placeOfDeath="", countryOfDeath="",
occupations = "", dayB="", monthB="", yearB="", dayD="", monthD="", yearD="",
occupation={}, idOccupation={}, upOccupation={}, citizenship={}, employer={},
influencedBy={}, edu={}, eduStart={}, eduEnd={}, docAdvisor={}, docStud={}, stu={},
pup={}, moth="", father="", genre={}, instrument={}, residence={}, residenceEnd={},
residenceSt={}, sibling={}, award={}, awardPIT={}, awardTW={}, awardPM={}, participantOf={},
notableWork={}, workLocation={}, academicDegree={}, academicDegreeDate={}, academicDegreeF={},
academicDegreeEdu={}, positionHeld={},positionHeldStart={},positionHeldEnd={},positionHeldPG={},
positionHeldPT={},positionHeldReplace={},positionHeldReplaceBy={}}
-- Точка входа
function AutoDescriptionHuman.launch(entity)
local successLaunchParsing, errCodeParsing, successLaunchForming, errCodeForming -- Признак успешного завершения и сообщения об ошибке парсинга и форминга соответственно
successLaunchParsing, errCodeParsing = pcall(function() AutoDescriptionHuman.parsing(entity) end) -- Парсим карточку Викиданных, тестируя функцию парсинга на ошибки.
if successLaunchParsing then successLaunchForming, errCodeForming = pcall(function() AutoDescriptionHuman.forming() end) end -- формируем переменные, тестируя функцию форминга на ошибки
if not successLaunchParsing or not successLaunchForming then
categories = categories .. "[[Kategorio:Paĝoj kun eraro en modulo]][[Kategorio:Paĝoj kun eraro en modulo AutoDescriptionHuman]]"
if errCodeParsing then categories = categories .. "[[Kategorio:Paĝoj kun eraro:" .. errCodeParsing .. "]]" end
if errCodeForming then categories = categories .. "[[Kategorio:Paĝoj kun eraro:" .. errCodeForming .. "]]" end
end
return details, description, categories
end
-- Последовательно проходим свойства в карточке викиданных, для формирования массива сущностей entitiesArray
function AutoDescriptionHuman.parsing(entity)
entitiesArray["P569"]=AutoDescriptionHuman.parseP569(entity)
entitiesArray["P570"]=AutoDescriptionHuman.parseP570(entity)
AutoDescriptionHuman.parseP19(entity)
AutoDescriptionHuman.parseP20(entity)
AutoDescriptionHuman.parseP21(entity)
AutoDescriptionHuman.parseP22(entity)
AutoDescriptionHuman.parseP25(entity)
AutoDescriptionHuman.parseP27(entity)
entitiesArray["P39"]=AutoDescriptionHuman.parseP39(entity)
entitiesArray["P69"]=AutoDescriptionHuman.parseP69(entity)
AutoDescriptionHuman.parseP101(entity)
entitiesArray["P106"]=AutoDescriptionHuman.parseP106(entity)
AutoDescriptionHuman.parseP108(entity)
entitiesArray["P136"]=AutoDescriptionHuman.parseP136(entity)
entitiesArray["P166"]=AutoDescriptionHuman.parseP166(entity)
entitiesArray["P184"]=AutoDescriptionHuman.parseP184(entity)
entitiesArray["P185"]=AutoDescriptionHuman.parseP185(entity)
entitiesArray["P463Q"]=AutoDescriptionHuman.parseP463(entity)
entitiesArray["P509"]=AutoDescriptionHuman.parseP509(entity)
entitiesArray["P512"]=AutoDescriptionHuman.parseP512(entity)
entitiesArray["P551"]=AutoDescriptionHuman.parseP551(entity)
AutoDescriptionHuman.parseP734(entity)
AutoDescriptionHuman.parseP735(entity)
entitiesArray["P737Q"]=AutoDescriptionHuman.parseP737(entity)
entitiesArray["P800"]=AutoDescriptionHuman.parseP800(entity)
entitiesArray["P802"]=AutoDescriptionHuman.parseP802(entity)
entitiesArray["P937"]=AutoDescriptionHuman.parseP937(entity)
entitiesArray["P1066"]=AutoDescriptionHuman.parseP1066(entity)
entitiesArray["P1196"]=AutoDescriptionHuman.parseP1196(entity)
entitiesArray["P1303"]=AutoDescriptionHuman.parseP1303(entity)
entitiesArray["P1344"]=AutoDescriptionHuman.parseP1344(entity)
AutoDescriptionHuman.parseP1559(entity)
entitiesArray["P2021"]=AutoDescriptionHuman.parseP2021(entity)
entitiesArray["P3373"]=AutoDescriptionHuman.parseP3373(entity)
end
function AutoDescriptionHuman.forming()
if(entitiesArray.langName ~= "" or entitiesArray["P569"] ~= "" or entitiesArray["P570"] ~= "") then
details = details .. "("
if(entitiesArray.langName ~= "") then details = details .. Langs.launch(entitiesArray.langName, entitiesArray.nativeName) .. "; " end
if(entitiesArray["P569"] ~= "" and entitiesArray["P570"] ~= "") then details = details .. "[[" .. entitiesArray["P569"] .. " jaro]]"
elseif (entitiesArray["P569"] ~= "") then details = details .. "naskiĝis [[" .. entitiesArray["P569"] .. " jaro]]"
end
if(entitiesArray["placeOfBirth"] ~= "") then details = details .. ", [[" .. entitiesArray["placeOfBirth"] .. "]]" end
if(entitiesArray["countryOfBirth"] ~= "") then details = details .. ", [[" .. entitiesArray["countryOfBirth"] .. "]]" end
if(entitiesArray["P569"] ~= "" and entitiesArray["P570"] ~= "") then details = details .. " — [[" .. entitiesArray["P570"] .. " jaro]]"
elseif (entitiesArray["P570"] ~= "") then details = details .. "mortis [[" .. entitiesArray["P570"] .. " jaro]]"
end
if(entitiesArray["placeOfDeath"] ~= "") then details = details .. ", [[" .. entitiesArray["placeOfDeath"] .. "]]" end
if(entitiesArray["countryOfDeath"] ~= "") then details = details .. ", [[" .. entitiesArray["countryOfDeath"] .. "]]" end
details = details .. ")"
end
if(entitiesArray["P734"] == nil) then
categories = categories .. "[[Kategorio:Familnomo ne estas konata (nil)]]"
elseif(entitiesArray["P734"] == "") then
categories = categories .. "[[Kategorio:Familnomo ne estas konata (empty)]]"
else
categories = categories .. "[[Kategorio:"..entitiesArray["P734"].." (samfamilinomuloj laŭ alfabeto)]]"
end
if(entitiesArray["P735"] == nil) then
categories = categories .. "[[Kategorio:Nomo ne estas konata (nil)]]"
elseif(entitiesArray["P735"] == "") then
categories = categories .. "[[Kategorio:Nomo ne estas konata (empty)]]"
else
categories = categories .. "[[Kategorio:"..entitiesArray["P735"].." (samnomuloj laŭ alfabeto)]]"
end
if (entitiesArray["occupation"][1] ~= "") then
for ki, vi in pairs (entitiesArray.occupation) do
if(ki=="1") then
if(entitiesArray["P21"] == "vira") then
description = description .. vi .. " "
elseif (ReturnGendered.launch(vi, entitiesArray["P21"], 2) ~= "") then
description = description .. ReturnGendered.launch(vi, entitiesArray["P21"], 2) .. " "
end
else
p=true
for i=1, (ki-1), 1 do
if (entitiesArray.occupation and entitiesArray.occupation[i] and string.find(vi, entitiesArray.occupation[i])) then
p=false
end
end
if(p~=false) then
if(entitiesArray["P21"] == "vira") then description = description .. "[[" .. vi .. "]]" .. ", "
else
local rg = ReturnGendered.launch(vi, entitiesArray["P21"], 2)
if (rg ~= nil and rg ~= "") then description = description .. "[[" .. rg .. "]]" .. ", " end
end
end
end
end
description=description:sub(1, #description - 2)
description = description .. ". "
end
if (entitiesArray["P101"][1] ~= "" and string.find(entitiesArray.P101Q, "Q")) then
description = description .. " <br><b>Okupiĝis pri</b> "
for ki, vi in pairs (entitiesArray.P101) do
if(Declension.declineWord(vi, 6) ~= "Logical error Declension.declineWord(arg): word not found") then description = description .. "[[" .. vi .. "|" .. Declension.declineWord(vi, 6) .. "]], "
else description = description .. "[[" .. vi .. "]], " end
end
description=description:sub(1, #description - 2)
description = description .. ". "
end
if(entitiesArray["P463Q"] ~= "") then
description = description .. "<br><b>Ano de organizaĵo:</b> " -- ReturnGendered.launch("Partoprenanto", entitiesArray["P21"], 2) .. " de organizaĵo: "
for ki, vi in pairs (entitiesArray.P463) do
description = description .. "[[" .. vi .. "]], "
end
description=description:sub(1, #description - 2)
description = description .. ". "
end
if(entitiesArray["P69"] == "edu") then
local i=1
description = description .. "<br><b>Edukeco:</b> "
for ki, vi in pairs (entitiesArray.edu) do
description = description .. "[[" .. vi .. "]]"
if(entitiesArray.eduStart[i] ~= "None") then description = description .. " de " .. "[[" .. entitiesArray.eduStart[i] .. " jaro]]" end
if(entitiesArray.eduEnd[i] ~= "None") then description = description .. " ĝis ".. "[[" .. entitiesArray.eduEnd[i] .. " jaro]]" end
i=i+1
description = description .. ", "
end
description=description:sub(1, #description - 2)
description=description..". "
end
if(entitiesArray["P512"] == "full") then
local len=0
for k, v in pairs (entitiesArray.academicDegree) do
len=len+1
end
if (len>1) then description = description .. "Sciencaj rangoj: "
else description = description .. "<br><b>Scienca rango:</b> " end
for k, v in pairs (entitiesArray.academicDegree) do
description = description .. v
if (entitiesArray.academicDegreeF[k] ~= "None" or entitiesArray.academicDegreeDate[k] ~= "None" or entitiesArray.academicDegreeEdu[k] ~= "None") then
description = description .. " ("
if(entitiesArray.academicDegreeDate[k] ~= "None") then
description = description .. "[[" .. entitiesArray.academicDegreeDate[k] .. " jaro]]"
if(entitiesArray.academicDegreeF[k] ~= "None") then description = description .. "; [[" .. entitiesArray.academicDegreeF[k] .. "]]" end
if(entitiesArray.academicDegreeEdu[k] ~= "None") then description = description .. "; [[" .. entitiesArray.academicDegreeEdu[k] .. "]]" end
elseif(entitiesArray.academicDegreeF[k] ~= "None") then
description = description .. "[[" .. entitiesArray.academicDegreeF[k] .. "]]"
if(entitiesArray.academicDegreeEdu[k] ~= "None") then description = description .. "; [[" .. entitiesArray.academicDegreeEdu[k] .. "]]" end
elseif(entitiesArray.academicDegreeEdu[k] ~= "None") then description = description .. "[[" .. entitiesArray.academicDegreeEdu[k] .. "]]" end
description = description .. ")"
end
description = description .. ", "
end
description=description:sub(1, #description - 2)
description=description..". "
end
if (entitiesArray["employer"][1] ~= "" and string.find(entitiesArray.P108Q, "Q")) then
description = description .. "<br><b>Laborloko:</b> "
for ki, vi in pairs (entitiesArray.employer) do
description = description .. "[[" .. vi .. "]], "
end
description=description:sub(1, #description - 2)
description = description .. ". "
end
if(entitiesArray["P737Q"] ~= "") then
local rg = ReturnGendered.launch("<b>Influita", entitiesArray["P21"], 3)
if (rg ~= nil and rg ~= "") then
description = description .. rg .. " de:</b> "
for ki, vi in pairs (entitiesArray.influencedBy) do
description = description .. "[[" .. vi .. "]], "
end
description=description:sub(1, #description - 2)
description = description .. ". "
end
end
if(entitiesArray["P184"] == "full") then
description = description .. "<br><b>Scienca gvidanto:</b> "
for ki, vi in pairs (entitiesArray.docAdvisor) do
description = description .. "[[" .. vi .. "]], "
end
description=description:sub(1, #description - 2)
description=description..". "
end
if(entitiesArray["P185"] == "full") then
local len = 0
for ki, vi in pairs (entitiesArray.docStud) do
len=ki
end
if(len>1) then description = description .. "Postdiplomaj studanтoj: "
else description = description .. "Postdiploma studanтo: " end
for ki, vi in pairs (entitiesArray.docStud) do
description = description .. "[[" .. vi .. "]], "
end
description=description:sub(1, #description - 2)
description=description..". "
end
if(entitiesArray["P802"] == "full") then
local len = 0
for ki, vi in pairs (entitiesArray.stu) do
len=ki
end
if(len>1) then description = description .. "Studantoj: "
else description = description .. "Studanto: " end
for ki, vi in pairs (entitiesArray.stu) do
description = description .. "[[" .. vi .. "]], "
end
description=description:sub(1, #description - 2)
description=description..". "
end
if(entitiesArray["P1066"] == "full") then
description = description .. "<b>Disĉiplo de:</b> "
for ki, vi in pairs (entitiesArray.pup) do
description = description .. "[[" .. vi .. "]], "
end
description=description:sub(1, #description - 2)
description=description..". "
end
if(entitiesArray["moth"] ~= "") then description = description .. "<br><b>Patrino:</b> [[" .. entitiesArray["moth"] .. "]]. " end
if(entitiesArray["father"] ~= "") then description = description .. "<b>Patro:</b> [[" .. entitiesArray["father"] .. "]]. " end
if(entitiesArray["P136"] == "full") then
local len = 0
for ki, vi in pairs (entitiesArray.stu) do
len=len+1
end
if(len>1) then description = description .. "Ĝenroj: "
else description = description .. "Ĝenro: " end
for ki, vi in pairs (entitiesArray.genre) do
description = description .. "[[" .. vi .. "]], "
end
description=description:sub(1, #description - 2)
description=description..". "
end
if(entitiesArray["P1303"] == "full") then
local len = 0
for ki, vi in pairs (entitiesArray.instrument) do
len=len+1
end
if(len>1) then description = description .. "<br><b>Muzikaj instrumentoj:</b> "
else description = description .. "<br><b>Muzika instrumento:</b> " end
for ki, vi in pairs (entitiesArray.instrument) do
description = description .. "[[" .. vi .. "]], "
end
description=description:sub(1, #description - 2)
description=description..". "
end
if(entitiesArray["P551"] == "full") then
local len = 0
for k, v in pairs (entitiesArray.residence) do
len=len+1
end
if(len>1) then description = description .. "<br><b>Loĝlokoj:</b> "
else description = description .. "<br><b>Loĝloko:</b> " end
for k, v in pairs (entitiesArray.residence) do
description = description .. "[[" .. v .. "]]"
if(entitiesArray.residenceSt[k] ~= "NoNe") then description = description .. " de " .. "[[" .. entitiesArray.residenceSt[k] .. " jaro]]" end
if(entitiesArray.residenceEnd[k] ~= "NoNe") then description = description .. " ĝis ".. "[[" .. entitiesArray.residenceEnd[k] .. " jaro]]" end
description = description .. ", "
end
description=description:sub(1, #description - 2)
description=description..". "
end
if(entitiesArray["P937"] == "full") then
local len = 0
for k, v in pairs (entitiesArray.workLocation) do
len=len+1
end
if(len>1) then description = description .. "<br><b>Lokoj de aktivado:</b> "
else description = description .. "<br><b>Lokoj de aktivado:</b> " end
for k, v in pairs (entitiesArray.workLocation) do
description = description .. "[[" .. v .. "]], "
end
description=description:sub(1, #description - 2)
description=description..". "
end
if(entitiesArray["P3373"] == "full") then
local len = 0
for k, v in pairs (entitiesArray.sibling) do
len=len+1
end
if(len>1) then description = description .. "Gefratoj: "
else description = description .. "Gefrato: " end
for k, v in pairs (entitiesArray.sibling) do
description = description .. "[[" .. v .. "]], "
end
description=description:sub(1, #description - 2)
description=description..". "
end
if(entitiesArray["P1344"] == "full") then
description = description .. "<br><b>Partoprenis en:</b> "
for k, v in pairs (entitiesArray.participantOf) do
description = description .. "[[" .. v .. "]], "
end
description=description:sub(1, #description - 2)
description=description..". "
end
if(entitiesArray["P166"] == "full") then
description = description .. "<br><b>Premioj kaj honorigoj:</b> "
for k, v in pairs (entitiesArray.award) do
description = description .. "[[" .. v .. "]]"
if(entitiesArray.awardPIT[k]~="") then description = description .. " ([[" .. entitiesArray.awardPIT[k] .. " jaro]]" end
if(entitiesArray.awardTW[k]~="") then description = description .. "; kune kun:" .. entitiesArray.awardTW[k] end
if(entitiesArray.awardPM[k]~="") then description = description .. "; premia fonduso: " .. entitiesArray.awardPM[k] end
if(entitiesArray.awardPIT[k]~="") then description = description .. ")" end
description = description .. ", "
end
description=description:sub(1, #description - 2)
description=description..". "
end
if(entitiesArray["P800"] == "full") then
description = description .. "<br><b>Elstaraj verkoj:</b> "
for k, v in pairs (entitiesArray.notableWork) do
description = description .. "«[[" .. v .. "]]», "
end
description=description:sub(1, #description - 2)
description=description..". "
end
if (entitiesArray["P39"] == "full") then
local len=0
for k, v in pairs (entitiesArray.positionHeld) do
len=len+1
end
if (len>1) then description = description .. "<br><b>Okupitaj postenoj:</b> "
else description = description .. "<br><b>Okupita posteno:</b> " end
for k, v in pairs (entitiesArray.positionHeld) do
description = description .. v
if(entitiesArray.positionHeldStart[k] ~= "None") then description = description .. " de [[" .. entitiesArray.positionHeldStart[k] .. " jaro]]" end
if(entitiesArray.positionHeldEnd[k] ~= "None") then description = description .. " ĝis [[" .. entitiesArray.positionHeldEnd[k] .. " jaro]]" end
if(entitiesArray.positionHeldPG[k] ~= "None" and entitiesArray.positionHeldPG[k] ~= nil) then description = description .. ": «[[" .. entitiesArray.positionHeldPG[k] .. "]]»" end
if(entitiesArray.positionHeldReplace[k] ~= "None") then description = description .. " post [[" .. entitiesArray.positionHeldReplace[k] .. "]]" end
if(entitiesArray.positionHeldReplaceBy[k] ~= "None") then description = description .. " antaŭ [[" .. entitiesArray.positionHeldReplaceBy[k] .. "]]" end
description = description .. "; "
end
description=description:sub(1, #description - 2)
description=description..". "
end
if(entitiesArray["P27"] ~= "") then
for ki, vi in pairs (entitiesArray.citizenship) do
categories = categories .. "[[Kategorio:Personoj:" .. vi .. "]]"
end
end
if(entitiesArray["P569"] ~= "") then
if(entitiesArray["dayB"] ~= nil and (string.find(entitiesArray["monthB"], "senco nekonata") == nil) and entitiesArray["dayB"] ~= "" and entitiesArray["monthB"] ~= "") then categories = categories .. " [[Kategorio:Naskiĝintaj en " .. entitiesArray["P569"] .. " jaro]]"
elseif (entitiesArray["monthB"] ~= "") then categories = categories .. " [[Kategorio:Naskiĝintaj en " .. Declension.declineWord(entitiesArray.monthB, 1) .. " " .. entitiesArray.yearB .. " jaro]]" end
end
if(entitiesArray["placeOfBirth"] ~= "") then
if (Declension.declineWord(entitiesArray["placeOfBirth"], 1) == "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Kategorio:Naskiĝloko:" .. entitiesArray["placeOfBirth"] .. "]]"
else categories = categories .. " [[Kategorio:Naskiĝintaj en " .. Declension.declineWord(entitiesArray["placeOfBirth"], 1).. "]]" end
end
if(entitiesArray["countryOfBirth"] ~= "") then
if (Declension.declineWord(entitiesArray["countryOfBirth"], 1) == "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Kategorio:Naskiĝloko:" .. entitiesArray["countryOfBirth"] .. "]]"
elseif (entitiesArray["countryOfBirth"] == "Francio") then categories = categories .. " [[Kategorio:Naskiĝintaj en " .. Declension.declineWord(entitiesArray["countryOfBirth"], 1).. "]]"
else categories = categories .. " [[Kategorio:Naskiĝintaj en " .. Declension.declineWord(entitiesArray["countryOfBirth"], 1).. "]]"
end
end
if(entitiesArray["dayB"] ~= "" and entitiesArray["dayB"] ~= nil and string.find(entitiesArray["monthB"], "senco neklaras") == nil) then categories = categories .. " [[Kategorio:Naskiĝintaj " .. entitiesArray["dayB"] .. " " .. entitiesArray["monthB"] .. "]]" end
if(entitiesArray["yearB"] ~= "" and entitiesArray["yearB"] ~= nil) then categories = categories .. " [[Kategorio:Naskiĝintaj en " .. entitiesArray["yearB"] .. " jaro]]" end
if(entitiesArray["P570"] ~= "") then categories = categories .. " [[Kategorio:Mortintaj " .. entitiesArray["P570"] .. " jaro]]" end
if(entitiesArray["placeOfDeath"] ~= "") then
if (Declension.declineWord(entitiesArray["placeOfDeath"], 1) == "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Kategorio:Loko de morto:" .. entitiesArray["placeOfDeath"] .. "]]"
else categories = categories .. " [[Kategorio:Mortintaj en " .. Declension.declineWord(entitiesArray["placeOfDeath"], 1).. "]]" end
end
if(entitiesArray["countryOfDeath"] ~= "") then
if (Declension.declineWord(entitiesArray["countryOfDeath"], 1) == "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Kategorio:Loko de morto:" .. entitiesArray["countryOfDeath"] .. "]]"
elseif (entitiesArray["countryOfDeath"] == "Francio") then categories = categories .. " [[Kategorio:Mortintaj en " .. Declension.declineWord(entitiesArray["countryOfDeath"], 1).. "]]"
else categories = categories .. " [[Kategorio:Mortintaj en " .. Declension.declineWord(entitiesArray["countryOfDeath"], 1).. "]]" end
end
if(entitiesArray["dayD"] ~= "" and entitiesArray["dayD"] ~= nil) then categories = categories .. " [[Kategorio:Mortintaj " .. entitiesArray["dayD"] .. " " .. entitiesArray["monthD"] .. "]]" end
if(entitiesArray["yearD"] ~= "" and entitiesArray["yearD"] ~= nil) then categories = categories .. " [[Kategorio:Mortintaj en " .. entitiesArray["yearD"] .. " jaro]]" end
if (entitiesArray["occupation"][1] ~= "") then
local p=false
local q=false
for ki, vi in pairs (entitiesArray.occupation) do
if(entitiesArray["P21"] ~= "vira" and Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) ~= "Logical error Declension.declineWord(arg): word not found") then
categories = categories .. "[[Kategorio:" .. Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) .. " laŭ alfabeto]]"
elseif(Declension.declineWord(vi, 7) ~= "Logical error Declension.declineWord(arg): word not found") then
categories = categories .. "[[Kategorio:" .. Declension.declineWord(vi, 7) .. " laŭ alfabeto]]"
else
p=true
categories = categories .. "[[Kategorio:Okupo:" .. vi .. "j]]"
end
if (Declension.declineWord(entitiesArray["countryOfBirth"], 1) == "Logical error Declension.declineWord(arg): word not found") then q=true
elseif (Declension.declineWord(vi, 7) ~= "Logical error Declension.declineWord(arg): word not found") then
if(entitiesArray["P21"] ~= "vira" and ReturnGendered.launch(vi, entitiesArray["P21"], 2)~="" and Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7)~= "Logical error Declension.declineWord(arg): word not found") then categories = categories .. " [[Kategorio:" .. Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) .. " " .. Declension.declineWord(entitiesArray["countryOfBirth"], 1).. "]]"
else categories = categories .. " [[Kategorio:" .. Declension.declineWord(vi, 7) .. " de " .. Declension.declineWord(entitiesArray["countryOfBirth"], 1).. "]]" end
end
if(entitiesArray.yearB ~= "" and Declension.declineWord(vi, 7) ~= "Logical error Declension.declineWord(arg): word not found") then
if(vi ~= "блогер" and vi ~= "Блогер") then
local yC=entitiesArray.yearB
if (#yC==4) then
if(entitiesArray["P21"] ~= "vira" and ReturnGendered.launch(vi, entitiesArray["P21"], 2)~="" and Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7)~= "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Kategorio:" .. Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) .. " de " .. Math.roman((yC:match('%d%d') + "1")) .. " jarcento]]"
else categories = categories .. "[[Kategorio:" .. Declension.declineWord(vi, 7) .. " de " .. Math.roman((yC:match('%d%d') + "1")) .. " jarcento]]" end
elseif (#yC==3) then
if(entitiesArray["P21"] ~= "vira" and ReturnGendered.launch(vi, entitiesArray["P21"], 2)~="" and Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7)~= "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Kategorio:" .. Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) .. " de " .. Math.roman((yC:match('%d') + "1")) .. " jarcento]]"
else categories = categories .. "[[Kategorio:" .. Declension.declineWord(vi, 7) .. " de " .. Math.roman((yC:match('%d') + "1")) .. " jarcento]]" end
else
if(entitiesArray["P21"] ~= "vira" and ReturnGendered.launch(vi, entitiesArray["P21"], 2)~="" and Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7)~= "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Kategorio:" .. Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) .. " de " .. Math.roman(("1")) .. " jarcento]]"
else categories = categories .. "[[Kategorio:" .. Declension.declineWord(vi, 7) .. " de " .. Math.roman(("1")) .. " jarcento]]" end
end
end
end
if(entitiesArray.yearD ~= "" and Declension.declineWord(vi, 7) ~= "Logical error Declension.declineWord(arg): word not found") then
if(vi ~= "блогер" and vi ~= "Блогер") then
local yC=entitiesArray.yearD
if (#yC==4) then
if(entitiesArray["P21"] ~= "vira" and ReturnGendered.launch(vi, entitiesArray["P21"], 2)~="" and Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7)~= "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Kategorio:" .. Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) .. " de " .. Math.roman((yC:match('%d%d') + "1")) .. " jarcento]]"
else categories = categories .. "[[Kategorio:" .. Declension.declineWord(vi, 7) .. " de " .. Math.roman((yC:match('%d%d') + "1")) .. " jarcento]]" end
elseif (#yC==3) then
if(entitiesArray["P21"] ~= "vira" and ReturnGendered.launch(vi, entitiesArray["P21"], 2)~="" and Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7)~= "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Kategorio:" .. Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) .. " de " .. Math.roman((yC:match('%d') + "1")) .. " jarcento]]"
else categories = categories .. "[[Kategorio:" .. Declension.declineWord(vi, 7) .. " de " .. Math.roman((yC:match('%d') + "1")) .. " jarcento]]" end
else
if(entitiesArray["P21"] ~= "vira" and ReturnGendered.launch(vi, entitiesArray["P21"], 2)~="" and Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7)~= "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Kategorio:" .. Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) .. " de " .. Math.roman(("1")) .. " jarcento]]"
else categories = categories .. "[[Kategorio:" .. Declension.declineWord(vi, 7) .. " de " .. Math.roman(("1")) .. " jarcento]]" end
end
end
end
end
if (p == true) then categories = categories .. "[[Kategorio:Profesioj sen deklinacio]]" end
if (q == true) then categories = categories .. "[[Kategorio:Landoj sen deklinacio]]" end
end
if(entitiesArray["upOccupation"][1] ~= "") then
local p=false
local q=false
for ki, vi in pairs (entitiesArray.upOccupation) do
if (vi ~= "bin") then
if(Declension.declineWord(vi, 7) == "Logical error Declension.declineWord(arg): word not found") then
p=true
categories = categories .. "[[Kategorio:Okupo:" .. vi .. "j]]"
else categories = categories .. "[[Kategorio:" .. Declension.declineWord(vi, 7) .. " laŭ alfabeto]]" end
if (Declension.declineWord(entitiesArray["countryOfBirth"], 1) == "Logical error Declension.declineWord(arg): word not found") then q=true
elseif (Declension.declineWord(vi, 7) ~= "Logical error Declension.declineWord(arg): word not found") then categories = categories .. " [[Kategorio:" .. Declension.declineWord(vi, 7) .. " " .. Declension.declineWord(entitiesArray["countryOfBirth"], 1).. "]]" end
if(entitiesArray.yearB ~= "" and Declension.declineWord(vi, 7) ~= "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Kategorio:" .. Declension.declineWord(vi, 7) .. " de " .. Math.roman((entitiesArray.yearB:match('%d%d') + "1")) .. " jarcento]]" end
if(entitiesArray.yearD ~= "" and Declension.declineWord(vi, 7) ~= "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Kategorio:" .. Declension.declineWord(vi, 7) .. " de " .. Math.roman((entitiesArray.yearD:match('%d%d') + "1")) .. " jarcento]]" end
end
end
if (p == true) then categories = categories .. "[[Kategorio:Profesioj sen deklinacio]]" end
if (q == true) then categories = categories .. "[[Kategorio:Landoj sen deklinacio]]" end
end
if(entitiesArray["P463Q"] ~= "") then
local p=false
for ki, vi in pairs (entitiesArray.P463) do
if(Declension.declineWord(vi, 2) == "Logical error Declension.declineWord(arg): word not found") then
p=true
categories = categories .. "[[Kategorio:" .. vi .. " (partoprenantoj)]]"
else categories = categories .. "[[Kategorio:Partoprenantoj de " .. vi .. "]]" end
end
if (p == true) then categories = categories .. "[[Kategorio:Organizaĵoj sen deklinacio]]" end
end
if(entitiesArray["P69"] == "edu") then
local p=false
for ki, vi in pairs (entitiesArray.edu) do
if(Declension.declineWord(vi, 2) == "Logical error Declension.declineWord(arg): word not found") then
p=true
categories = categories .. "[[Kategorio:Finlernintoj de " .. vi .. "]]" end
end
end
if(entitiesArray["P551"] == "full") then
local p=false
for ki, vi in pairs (entitiesArray.residence) do
if(Declension.declineWord(vi, 2) == "Logical error Declension.declineWord(arg): word not found") then
p=true
categories = categories .. "[[Kategorio:Loĝloko:" .. vi .. " ]]"
else categories = categories .. "[[Kategorio:Loĝantoj " .. Declension.declineWord(vi, 2) .. "]]" end
end
if (p == true) then categories = categories .. "[[Kategorio:Urboj sen deklinacio]]" end
end
if(entitiesArray["P166"] == "full") then
local p=false
for ki, vi in pairs (entitiesArray.award) do
if(Declension.declineWord(vi, 2) == "Logical error Declension.declineWord(arg): word not found") then
p=true
categories = categories .. "[[Kategorio:" .. vi .. " (honorigitaj)]]"
else categories = categories .. "[[Kategorio:Honorigitaj " .. Declension.declineWord(vi, 2) .. "]]" end
end
if (p == true) then categories = categories .. "[[Kategorio:Honorigoj sen deklinacio]]" end
end
if(entitiesArray["P1344"] == "full") then
local p=false
for ki, vi in pairs (entitiesArray.participantOf) do
if(Declension.declineWord(vi, 2) == "Logical error Declension.declineWord(arg): word not found") then
p=true
categories = categories .. "[[Kategorio:" .. vi .. " (partoprenantoj)]]"
else categories = categories .. "[[Kategorio:Partoprenantoj de " .. vi .. "]]" end
end
if (p == true) then categories = categories .. "[[Kategorio:Aranĝoj sen deklinacio]]" end
end
end
function AutoDescriptionHuman.parseP19(entity)
local values=entity:formatPropertyValues("P19",mw.wikibase.entity.claimRanks).value
if(values ~= "") then entitiesArray["placeOfBirth"]=values end
local q
local p19Statements=mw.wikibase.getBestStatements(entity:getId(), 'P19' )
for ki, vi in pairs (p19Statements) do
q = vi['mainsnak']['datavalue']['value']['id']
end
if q== nil then
for ki, vi in pairs (p19Statements) do
q = vi['references']['mainsnak']['datavalue']['value']['id']
end
end
if(q ~= nil) then local p17Statements=mw.wikibase.getBestStatements(q, 'P17' )
local i=1
local country=""
local year=MathTonumber.integerModule(entitiesArray["yearB"])
for ki, vi in pairs (p17Statements) do
local start=""
local enD=""
if (i == 1) then country=mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
else
if(vi['qualifiers'] ~= nil) then
if((vi['qualifiers']['P582'] ~= nil)) then enD=MathTonumber.integerModule(vi['qualifiers']['P582'][1]['datavalue']['value']['time']) end
if((vi['qualifiers']['P580'] ~= nil)) then start=MathTonumber.integerModule(vi['qualifiers']['P580'][1]['datavalue']['value']['time']) end
else country=mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id']) end
if(enD ~= "" and (enD-year)>0) then
if(start ~= "") then
if(year-start > 0) then country=mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id']) end
else country=mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id']) end
end
end
i=i+1
end
entitiesArray["countryOfBirth"] = entitiesArray["countryOfBirth"] .. country
end
local p19Statements=entity:getAllStatements("P19")
for ki, vi in pairs (p19Statements) do
if(vi['qualifiers'] ~= nil and vi['qualifiers']['P17'] ~= nil) then entitiesArray["countryOfBirth"] = mw.wikibase.getLabel(vi['qualifiers']['P17'][1]['datavalue']['value']['id']) end
end
end
function AutoDescriptionHuman.parseP20(entity)
local values=entity:formatPropertyValues("P20",mw.wikibase.entity.claimRanks).value
if(values ~= "") then entitiesArray["placeOfDeath"]=values end
local q
local p20Statements=mw.wikibase.getBestStatements(entity:getId(), 'P20' )
for ki, vi in pairs (p20Statements) do
if(vi['mainsnak'] ~= nil and vi['mainsnak']['datavalue'] ~= nil) then
q = vi['mainsnak']['datavalue']['value']['id']
end
end
if q== nil then
for ki, vi in pairs (p20Statements) do
q = vi['references']['mainsnak']['datavalue']['value']['id']
end
end
if(q ~= nil) then local p17Statements=mw.wikibase.getBestStatements(q, 'P17' )
local i=1
local country=""
local year=MathTonumber.integerModule(entitiesArray["yearD"])
for ki, vi in pairs (p17Statements) do
local start=""
local enD=""
if (i == 1) then country=mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
else
if(vi['qualifiers'] ~= nil) then
if((vi['qualifiers']['P582'] ~= nil)) then enD=MathTonumber.integerModule(vi['qualifiers']['P582'][1]['datavalue']['value']['time']) end
if((vi['qualifiers']['P580'] ~= nil)) then start=MathTonumber.integerModule(vi['qualifiers']['P580'][1]['datavalue']['value']['time']) end
else country=mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id']) end
if(enD ~= "" and (year-enD)<0) then
if(start ~= "") then
if(year-start > 0) then country=mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id']) end
else country=mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id']) end
end
end
i=i+1
end
entitiesArray["countryOfDeath"] = country
end
local p20Statements=entity:getAllStatements("P20")
for ki, vi in pairs (p20Statements) do
if(vi['qualifiers'] ~= nil and vi['qualifiers']['P17'] ~= nil) then entitiesArray["countryOfDeath"] = mw.wikibase.getLabel(vi['qualifiers']['P17'][1]['datavalue']['value']['id']) end
end
end
function AutoDescriptionHuman.parseP21(entity)
local values=entity:formatPropertyValues("P21",mw.wikibase.entity.claimRanks).value
entitiesArray["P21"]=values
if (values == "vira") then male="1"
elseif (values == "ina") then female="1" end
end
function AutoDescriptionHuman.parseP22(entity)
local values=entity:formatPropertyValues("P22",mw.wikibase.entity.claimRanks).value
if(values ~= nil) then entitiesArray["father"]=values
else entitiesArray["father"]="" end
end
function AutoDescriptionHuman.parseP25(entity)
local values=entity:formatPropertyValues("P25",mw.wikibase.entity.claimRanks).value
if(values ~= nil) then entitiesArray["moth"]=values
else entitiesArray["moth"]="" end
end
function AutoDescriptionHuman.parseP27(entity)
local values=entity:formatPropertyValues("P27",mw.wikibase.entity.claimRanks).value
entitiesArray["P27"]=values
if(values ~= nil) then
local p27Statements=entity:getAllStatements("P27")
local i=1
for ki, vi in pairs (p27Statements) do
if(vi['mainsnak']['datavalue'] ~= nil and vi['mainsnak']['datavalue']['value'] ~= nil and vi['mainsnak']['datavalue']['value']['id'] ~= nil) then
entitiesArray["citizenship"][i]=mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
i=i+1
end
end
end
end
function AutoDescriptionHuman.parseP39(entity)
local p39Statements=entity:getAllStatements("P39")
local value=""
for k, v in pairs (p39Statements) do
entitiesArray.positionHeld[k]=mw.wikibase.getLabel(v['mainsnak']['datavalue']['value']['id'])
entitiesArray.positionHeldStart[k]="None"
entitiesArray.positionHeldEnd[k]="None"
entitiesArray.positionHeldPG[k]="None"
entitiesArray.positionHeldPT[k]="None"
entitiesArray.positionHeldReplace[k]="None"
entitiesArray.positionHeldReplaceBy[k]="None"
if(v['qualifiers'] ~= nil) then
if(v['qualifiers'] ~= nil and v['qualifiers']['P580'] ~= nil
and v['qualifiers']['P580'][1] ~= nil and v['qualifiers']['P580'][1]['datavalue'] ~= nil
and v['qualifiers']['P580'][1]['datavalue']['value']['time'] ~= nil)
then entitiesArray.positionHeldStart[k]=MathTonumber.integerModule(v['qualifiers']['P580'][1]['datavalue']['value']['time'])
else entitiesArray.positionHeldStart[k]="None" end
if(v['qualifiers'] ~= nil
and v['qualifiers']['P582'] ~= nil
and v['qualifiers']['P582'][1] ~= nil
and v['qualifiers']['P582'][1]['datavalue'] ~= nil
and v['qualifiers']['P582'][1]['datavalue']['value'] ~= nil
and v['qualifiers']['P582'][1]['datavalue']['value']['time'] ~= nil
and v['qualifiers']['P582'][1]['snaktype'] ~= nil -- Что это и следующая строка и зачем в этом запросе?
and v['qualifiers']['P582'][1]['snaktype'] ~= "novalue")
then entitiesArray.positionHeldEnd[k]=MathTonumber.integerModule(v['qualifiers']['P582'][1]['datavalue']['value']['time'])
else entitiesArray.positionHeldEnd[k]="None" end
if(v['qualifiers']['P4100'] ~= nil and v['qualifiers']['P4100'][1] ~= nil and v['qualifiers']['P4100'][1]['datavalue'] ~= nil and v['qualifiers']['P4100'][1]['datavalue']['value']['id']~=nil and v['qualifiers']['P4100'][1]['datavalue']['value']['id']~="")
then entitiesArray.positionHeldPG[k]=mw.wikibase.getLabel(v['qualifiers']['P4100'][1]['datavalue']['value']['id'])
else entitiesArray.positionHeldPG[k]="None" end
if(v['qualifiers']['P2937'] ~= nil)
then entitiesArray.positionHeldPT[k]=mw.wikibase.getLabel(v['qualifiers']['P2937'][1]['datavalue']['value']['id'])
else entitiesArray.positionHeldPG[k]="None" end
if(v['qualifiers']['P1365'] ~= nil and v['qualifiers']['P1365'][1] ~= nil and v['qualifiers']['P1365'][1]['datavalue'] ~= nil and v['qualifiers']['P1365'][1]['datavalue']['value'] ~= nil)
then entitiesArray.positionHeldReplace[k]=mw.wikibase.getLabel(v['qualifiers']['P1365'][1]['datavalue']['value']['id'])
else entitiesArray.positionHeldReplace[k]="None" end
if(v['qualifiers']['P1366'] ~= nil and v['qualifiers']['P1366'][1] ~= nil and v['qualifiers']['P1366'][1]['datavalue'] ~= nil and v['qualifiers']['P1366'][1]['datavalue']['value'] ~= nil)
then entitiesArray.positionHeldReplaceBy[k]=mw.wikibase.getLabel(v['qualifiers']['P1366'][1]['datavalue']['value']['id'])
else entitiesArray.positionHeldReplaceBy[k]="None" end
end
value=v['mainsnak']['datavalue']['value']['id']
end
if(string.find(value, "Q")) then return "full"
else return "" end
end
function AutoDescriptionHuman.parseP69(entity)
local p69Statements=entity:getAllStatements("P69")
local i=1
local value=""
for ki, vi in pairs (p69Statements) do
if(vi['mainsnak'] ~= nil and vi['mainsnak']['datavalue'] ~= nil and vi['mainsnak']['datavalue']['value'] ~= nil and vi['mainsnak']['datavalue']['value']['id'] ~= nil) then
entitiesArray.edu[i]=mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
end
if(vi['qualifiers'] ~= nil) then
if(vi['qualifiers']['P580'] ~= nil and vi['qualifiers']['P580'][1] ~= nil and vi['qualifiers']['P580'][1]['datavalue'] ~= nil
and vi['qualifiers']['P580'][1]['datavalue']['value'] ~= nil and vi['qualifiers']['P580'][1]['datavalue']['value']['time'] ~= nil)
then
entitiesArray.eduStart[i]=MathTonumber.integerModule(vi['qualifiers']['P580'][1]['datavalue']['value']['time'])
else entitiesArray.eduStart[i]="None" end
if(vi['qualifiers']['P582'] ~= nil and vi['qualifiers']['P582'][1] ~= nil and vi['qualifiers']['P582'][1]['datavalue'] ~= nil
and vi['qualifiers']['P582'][1]['datavalue']['value'] ~= nil and vi['qualifiers']['P582'][1]['datavalue']['value']['time'] ~= nil)
then
entitiesArray.eduEnd[i]=MathTonumber.integerModule(vi['qualifiers']['P582'][1]['datavalue']['value']['time'])
else entitiesArray.eduEnd[i]="None" end
else entitiesArray.eduStart[i]="None" entitiesArray.eduEnd[i]="None" end
i=i+1
if(vi['mainsnak'] ~= nil and vi['mainsnak']['datavalue'] ~= nil and vi['mainsnak']['datavalue']['value'] ~= nil and vi['mainsnak']['datavalue']['value']['id'] ~= nil) then
value=vi['mainsnak']['datavalue']['value']['id']
end
end
if(string.find(value, "Q")) then return "edu"
else return "" end
end
function AutoDescriptionHuman.parseP101(entity)
local p101Statements=entity:getAllStatements("P101")
local i=1
for ki, vi in pairs (p101Statements) do
entitiesArray.P101[i]= mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
entitiesArray.P101Q=vi['mainsnak']['datavalue']['value']['id']
i=i+1
end
end
function AutoDescriptionHuman.parseP106(entity)
local p106Statements = entity:getAllStatements("P106")
local i=1
for ki, vi in pairs (p106Statements) do
entitiesArray.occupation[i]= mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
entitiesArray.idOccupation[i]= vi['mainsnak']['datavalue']['value']['id']
i=i+1
end
i=1
for ki, vi in pairs (entitiesArray.occupation) do
local j=1
local p279Statements=mw.wikibase.getBestStatements(entitiesArray.idOccupation[i], 'P279' )
for kj, vj in pairs (p279Statements) do
entitiesArray["upOccupation"][i] = mw.wikibase.getLabel(vj['mainsnak']['datavalue']['value']['id'])
for kz, vz in pairs (entitiesArray.occupation) do
if(vz==entitiesArray["upOccupation"][i]) then entitiesArray["upOccupation"][i]="bin" end
end
end
if (entitiesArray["upOccupation"][i] == "okupo" or entitiesArray["upOccupation"][i] == "persono") then entitiesArray["upOccupation"][i]="bin" end
if (entitiesArray["upOccupation"][i] == "ludanto") then entitiesArray["upOccupation"][i]="sportsmeno" end
i=i+1
end
end
function AutoDescriptionHuman.parseP108(entity)
local p108Statements = entity:getAllStatements("P108")
local i=1
for ki, vi in pairs (p108Statements) do
if vi['mainsnak']['datavalue'] == nil then
-- do nothing and go to the next iteration
else
entitiesArray.employer[i]= mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
entitiesArray.P108Q=vi['mainsnak']['datavalue']['value']['id']
i=i+1
end
end
end
function AutoDescriptionHuman.parseP136(entity)
local p136Statements = entity:getAllStatements("P136")
local i=1
local value=""
for ki, vi in pairs (p136Statements) do
entitiesArray.genre[i]=mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
value=vi['mainsnak']['datavalue']['value']['id']
i=i+1
end
if(string.find(value, "Q")) then return "full"
else return "" end
end
function AutoDescriptionHuman.parseP166(entity)
local p166Statements = entity:getAllStatements("P166")
local value=""
for k, v in pairs (p166Statements) do
entitiesArray.award[k]=mw.wikibase.getLabel(v['mainsnak']['datavalue']['value']['id'])
value=v['mainsnak']['datavalue']['value']['id']
entitiesArray.awardPIT[k]=""
entitiesArray.awardTW[k]=""
entitiesArray.awardPM[k]=""
if(v['qualifiers'] ~= nil) then
if(v['qualifiers']['P1706'] ~= nil) then
local p1706Statements = v['qualifiers']['P1706']
for ki, vi in pairs (p1706Statements) do
entitiesArray.awardTW[k]=entitiesArray.awardTW[k] .. " [[" .. mw.wikibase.getLabel(vi['datavalue']['value']['id']) .. "]]"
end
end
if(v['qualifiers']['P585'] ~= nil and v['qualifiers']['P585'][1] ~= nil
and v['qualifiers']['P585'][1]['datavalue'] ~= nil and v['qualifiers']['P585'][1]['datavalue']['value'] ~= nil
and v['qualifiers']['P585'][1]['datavalue']['value']['time'] ~= nil) then
entitiesArray.awardPIT[k] = MathTonumber.integerModule(v['qualifiers']['P585'][1]['datavalue']['value']['time'])
end
if(v['qualifiers']['P2121'] ~= nil and v['qualifiers']['P2121'][1] ~= nil
and v['qualifiers']['P2121'][1]['datavalue'] ~= nil and v['qualifiers']['P2121'][1]['datavalue']['value'] ~= nil
and v['qualifiers']['P2121'][1]['datavalue']['value']['amount'] ~= nil) then
entitiesArray.awardPM[k] = MathTonumber.integerModule(v['qualifiers']['P2121'][1]['datavalue']['value']['amount'])
end
end
end
if(string.find(value, "Q")) then return "full"
else return "" end
end
function AutoDescriptionHuman.parseP184(entity)
local p184Statements = entity:getAllStatements("P184")
local i=1
local value=""
for ki, vi in pairs (p184Statements) do
entitiesArray.docAdvisor[i]=mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
value=vi['mainsnak']['datavalue']['value']['id']
i=i+1
end
if(string.find(value, "Q")) then return "full"
else return "" end
end
function AutoDescriptionHuman.parseP185(entity)
local p185Statements = entity:getAllStatements("P185")
local i=1
local value=""
for ki, vi in pairs (p185Statements) do
entitiesArray.docStud[i]=mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
value=vi['mainsnak']['datavalue']['value']['id']
i=i+1
end
if(string.find(value, "Q")) then return "full"
else return "" end
end
function AutoDescriptionHuman.parseP463(entity)
local p463Statements = entity:getAllStatements("P463")
local i=1
for ki, vi in pairs (p463Statements) do
entitiesArray.P463[i]= mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
entitiesArray.P463Q=vi['mainsnak']['datavalue']['value']['id']
i=i+1
end
if(string.find(entitiesArray.P463Q, "Q")) then return entitiesArray.P463Q
else return "" end
end
function AutoDescriptionHuman.parseP509(entity)
local value = entity:formatPropertyValues("P509",mw.wikibase.entity.claimRanks).value
if(value ~= "") then return value
else return "" end
end
function AutoDescriptionHuman.parseP512(entity)
local p512Statements = entity:getAllStatements("P512")
local value = ""
local i=1
for k, v in pairs (p512Statements) do
entitiesArray.academicDegree[i]=mw.wikibase.getLabel(v['mainsnak']['datavalue']['value']['id'])
entitiesArray.academicDegreeDate[i]="None"
entitiesArray.academicDegreeF[i]="None"
entitiesArray.academicDegreeEdu[i]="None"
if(v['qualifiers'] ~= nil) then
if(v['qualifiers']['P101'] ~= nil) then entitiesArray.academicDegreeF[k]=mw.wikibase.getLabel(v['qualifiers']['P101'][1]['datavalue']['value']['id'])
else entitiesArray.academicDegreeF[k]="None" end
if(v['qualifiers']['P69'] ~= nil) then entitiesArray.academicDegreeEdu[k]=mw.wikibase.getLabel(v['qualifiers']['P69'][1]['datavalue']['value']['id'])
else entitiesArray.academicDegreeEdu[k]="None" end
if(v['qualifiers']['P813'] ~= nil) then entitiesArray.academicDegreeDate[k]=v['qualifiers']['P813'][1]['datavalue']['value']['time']
else entitiesArray.academicDegreeDate[k]="None" end
if(v['qualifiers']['P585'] ~= nil) then entitiesArray.academicDegreeDate[k]=MathTonumber.integerModule(v['qualifiers']['P585'][1]['datavalue']['value']['time'])
elseif (entitiesArray.academicDegreeDate[k] == "None") then entitiesArray.academicDegreeDate[k]="None" end
end
value=v['mainsnak']['datavalue']['value']['id']
i=i+1
end
if(string.find(value, "Q")) then return "full"
else return "" end
end
function AutoDescriptionHuman.parseP551(entity)
local p551Statements = entity:getAllStatements("P551")
local value = ""
local i=1
for k, v in pairs (p551Statements) do
entitiesArray.residence[i]=mw.wikibase.getLabel(v['mainsnak']['datavalue']['value']['id'])
entitiesArray.residenceSt[i]="NoNe"
entitiesArray.residenceEnd[i]="NoNe"
if(v['qualifiers'] ~= nil) then
if(v['qualifiers']['P582'] ~= nil and v['qualifiers']['P582'][1] ~= nil
and v['qualifiers']['P582'][1]['datavalue'] ~= nil and v['qualifiers']['P582'][1]['datavalue']['value'] ~= nil
and v['qualifiers']['P582'][1]['datavalue']['value']['time'] ~= nil) then
entitiesArray.residenceEnd[i]=MathTonumber.integerModule(v['qualifiers']['P582'][1]['datavalue']['value']['time'])
else entitiesArray.residenceEnd[i]="NoNe" end
if(v['qualifiers']['P580'] ~= nil and v['qualifiers']['P580'][1] ~= nil
and v['qualifiers']['P580'][1]['datavalue'] ~= nil and v['qualifiers']['P580'][1]['datavalue']['value'] ~= nil
and v['qualifiers']['P580'][1]['datavalue']['value']['time'] ~= nil) then
entitiesArray.residenceSt[i]=MathTonumber.integerModule(v['qualifiers']['P580'][1]['datavalue']['value']['time'])
else entitiesArray.residenceSt[i]="NoNe" end
end
value=v['mainsnak']['datavalue']['value']['id']
i=i+1
end
if(string.find(value, "Q")) then return "full"
else return "" end
end
function AutoDescriptionHuman.parseP569(entity)
local valuesP=entity:formatPropertyValues("P569", { mw.wikibase.entity.claimRanks.RANK_PREFERRED }).value
local valuesN=entity:formatPropertyValues("P569", { mw.wikibase.entity.claimRanks.RANK_NORMAL }).value
local valuesC=entity:formatPropertyValues("P569",mw.wikibase.entity.claimRanks).value
local values=""
if(valuesP ~= nil) then values=valuesP end
if(values == "" and valuesN ~= nil) then values=valuesN end
if(values == "" and valuesC ~= nil) then values=valuesC end
if(values ~= "") then
entitiesArray["dayB"]=values:match"(%d+)[-/.%s]"
entitiesArray["monthB"]=string.gsub(values, '[^a-z]', '' )
if(string.find(values, "februaro")) then entitiesArray["monthB"]="februaro"
elseif (string.find(values, "januaro")) then entitiesArray["monthB"]="januaro"
elseif (string.find(values, "marto")) then entitiesArray["monthB"]="marto"
elseif (string.find(values, "aprilo")) then entitiesArray["monthB"]="aprilo"
elseif (string.find(values, "jun.")) then entitiesArray["monthB"]="junio"
elseif (string.find(values, "jun")) then entitiesArray["monthB"]="junio"
elseif (string.find(values, "junio")) then entitiesArray["monthB"]="junio"
elseif (string.find(values, "julio")) then entitiesArray["monthB"]="julio"
elseif (string.find(values, "aŭgusto")) then entitiesArray["monthB"]="aŭgusto"
elseif (string.find(values, "septembro")) then entitiesArray["monthB"]="septembro"
elseif (string.find(values, "oktobro")) then entitiesArray["monthB"]="oktobro"
elseif (string.find(values, "novembro")) then entitiesArray["monthB"]="novembro"
elseif (string.find(values, "decembro")) then entitiesArray["monthB"]="decembro"
elseif (string.find(values, "senco ne klaras")) then entitiesArray["dayB"]="" entitiesArray["monthB"]="" entitiesArray["yearB"]=""
end
entitiesArray["yearB"]=values:match(' %d*%d%d')
if(#values <= 4) then
entitiesArray["dayB"]=""
entitiesArray["monthB"]=""
entitiesArray["yearB"]=values
elseif(entitiesArray["yearB"] ~= nil) then entitiesArray["yearB"]=entitiesArray["yearB"]:sub(2,#entitiesArray["yearB"]) end
local result_data = ""
if entitiesArray["dayB"] ~= nil and entitiesArray["dayB"] ~= "" then result_data = result_data .. entitiesArray["dayB"] .. " " end
if entitiesArray["monthB"] ~= nil and entitiesArray["monthB"] ~= "" then result_data = result_data .. entitiesArray["monthB"] .. " " end
if entitiesArray["yearB"] ~= nil and entitiesArray["yearB"] ~= "" then result_data = result_data .. entitiesArray["yearB"] .. " " end
return result_data
else return ""
end
end
function AutoDescriptionHuman.parseP570(entity)
local valuesP=entity:formatPropertyValues("P570", { mw.wikibase.entity.claimRanks.RANK_PREFERRED }).value
local valuesN=entity:formatPropertyValues("P570", { mw.wikibase.entity.claimRanks.RANK_NORMAL }).value
local valuesC=entity:formatPropertyValues("P570",mw.wikibase.entity.claimRanks).value
local values=""
if(valuesP ~= nil) then values=valuesP end
if(values == "" and valuesN ~= nil) then values=valuesN end
if(values == "" and valuesC ~= nil) then values=valuesC end
if(values ~= "") then
entitiesArray["dayD"]=values:match"(%d+)[-/.%s]"
entitiesArray["monthD"]=string.gsub(values, '[^a-z]', '' )
if(string.find(values, "februaro")) then entitiesArray["monthD"]="februaro"
elseif (string.find(values, "novembro")) then entitiesArray["monthD"]="novembro"
elseif (string.find(values, "septembro")) then entitiesArray["monthD"]="septembro"
elseif (string.find(values, "aprilo")) then entitiesArray["monthD"]="aprilo"
elseif (string.find(values, "julio")) then entitiesArray["monthD"]="julio"
elseif (string.find(values, "marto")) then entitiesArray["monthD"]="marto"
elseif (string.find(values, "junio")) then entitiesArray["monthD"]="junio"
elseif (string.find(values, "decembro")) then entitiesArray["monthD"]="decembro"
elseif (string.find(values, "januaro")) then entitiesArray["monthD"]="januaro"
elseif (string.find(values, "aŭgusto")) then entitiesArray["monthD"]="aŭgusto"
elseif (string.find(values, "oktobro")) then entitiesArray["monthD"]="oktobro"
elseif (string.find(values, "senco ne klaras")) then entitiesArray["dayD"]="" entitiesArray["monthD"]="" entitiesArray["yearD"]=""
end
entitiesArray["yearD"]=values:match(' %d*%d%d')
if(#values <= 4) then
entitiesArray["dayD"]=""
entitiesArray["monthD"]=""
entitiesArray["yearD"]=values
elseif(entitiesArray["yearD"] ~= nil) then entitiesArray["yearD"]=entitiesArray["yearD"]:sub(2,#entitiesArray["yearD"])
end
return values
else return ""
end
end
function AutoDescriptionHuman.parseP734(entity)
local p734Statement = mw.wikibase.getBestStatements(entity:getId(), "P734")
if(p734Statement ~= nil) then
for ki, vi in pairs (p734Statement) do
if(vi["mainsnak"] ~= nil
and vi["mainsnak"]["datavalue"] ~= nil
and vi["mainsnak"]["datavalue"]["value"] ~= nil
and vi["mainsnak"]["datavalue"]["value"]["id"] ~= nil) then
local givenNameId = vi["mainsnak"]["datavalue"]["value"]["id"]
if(givenNameId ~= nil and givenNameId ~= "") then
local givenName = mw.wikibase.getLabelByLang(givenNameId, "eo")
if(givenName ~= nil) then entitiesArray["P734"] = givenName end
end
end
end
end
return ""
end
function AutoDescriptionHuman.parseP735(entity)
local p735Statement = mw.wikibase.getBestStatements(entity:getId(), "P735")
if(p735Statement ~= nil) then
for ki, vi in pairs (p735Statement) do
if(vi["mainsnak"] ~= nil
and vi["mainsnak"]["datavalue"] ~= nil
and vi["mainsnak"]["datavalue"]["value"] ~= nil
and vi["mainsnak"]["datavalue"]["value"]["id"] ~= nil) then
local givenNameId = vi["mainsnak"]["datavalue"]["value"]["id"]
if(givenNameId ~= nil and givenNameId ~= "") then
local givenName = mw.wikibase.getLabelByLang(givenNameId, "eo")
if(givenName ~= nil) then entitiesArray["P735"] = givenName end
end
end
end
end
return ""
end
function AutoDescriptionHuman.parseP737(entity)
local p737Statements = entity:getAllStatements("P737")
local i=1
for ki, vi in pairs (p737Statements) do
entitiesArray.influencedBy[i]= mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
entitiesArray.P737Q=vi['mainsnak']['datavalue']['value']['id']
i=i+1
end
if(string.find(entitiesArray.P737Q, "Q")) then return entitiesArray.P737Q
else return "" end
end
function AutoDescriptionHuman.parseP800(entity)
local p800Statements = entity:getAllStatements("P800")
local i=1
local value=""
for ki, vi in pairs (p800Statements) do
entitiesArray.notableWork[i]= mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
value=vi['mainsnak']['datavalue']['value']['id']
i=i+1
end
if(string.find(value, "Q")) then return "full"
else return "" end
end
function AutoDescriptionHuman.parseP802(entity)
local p802Statements = entity:getAllStatements("P802")
local i=1
local value=""
for ki, vi in pairs (p802Statements) do
entitiesArray.stu[i]= mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
value=vi['mainsnak']['datavalue']['value']['id']
i=i+1
end
if(string.find(value, "Q")) then return "full"
else return "" end
end
function AutoDescriptionHuman.parseP937(entity)
local p937Statements = entity:getAllStatements("P937")
local i=1
local value=""
for ki, vi in pairs (p937Statements) do
entitiesArray.workLocation[i]= mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
value=vi['mainsnak']['datavalue']['value']['id']
i=i+1
end
if(string.find(value, "Q")) then return "full"
else return "" end
end
function AutoDescriptionHuman.parseP1066(entity)
local p1066Statements = entity:getAllStatements("P1066")
local i=1
local value=""
for ki, vi in pairs (p1066Statements) do
entitiesArray.pup[i]= mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
value=vi['mainsnak']['datavalue']['value']['id']
i=i+1
end
if(string.find(value, "Q")) then return "full"
else return "" end
end
function AutoDescriptionHuman.parseP1196(entity)
local value = entity:formatPropertyValues("P1196",mw.wikibase.entity.claimRanks).value
if(value ~= "") then return value
else return "" end
end
function AutoDescriptionHuman.parseP1303(entity)
local p1303Statements = entity:getAllStatements("P1303")
local i=1
local value=""
for ki, vi in pairs (p1303Statements) do
entitiesArray.instrument[i]=mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
value=vi['mainsnak']['datavalue']['value']['id']
i=i+1
end
if(string.find(value, "Q")) then return "full"
else return "" end
end
function AutoDescriptionHuman.parseP1344(entity)
local p1344Statements = entity:getAllStatements("P1344")
local i=1
local value=""
for ki, vi in pairs (p1344Statements) do
entitiesArray.participantOf[i]=mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id'])
value=vi['mainsnak']['datavalue']['value']['id']
i=i+1
end
if(string.find(value, "Q")) then return "full"
else return "" end
end
function AutoDescriptionHuman.parseP1559(entity)
local p1559Statements = entity:getAllStatements("P1559")
for ki, vi in pairs (p1559Statements) do
if (vi['mainsnak']['datavalue']['value']['language']) then entitiesArray.langName=vi['mainsnak']['datavalue']['value']['language'] end
if (vi['mainsnak']['datavalue']['value']['text']) then entitiesArray.nativeName=vi['mainsnak']['datavalue']['value']['text'] end
end
end
function AutoDescriptionHuman.parseP2021(entity)
local value = entity:formatPropertyValues("P2021",mw.wikibase.entity.claimRanks).value
if(value ~= "") then return value
else return "" end
end
function AutoDescriptionHuman.parseP3373(entity)
local p3373Statements = entity:getAllStatements("P3373")
local value=""
for k, v in pairs (p3373Statements) do
entitiesArray.sibling[k]=mw.wikibase.getLabel(v['mainsnak']['datavalue']['value']['id'])
value=v['mainsnak']['datavalue']['value']['id']
end
if(string.find(value, "Q")) then return "full" end
end
return AutoDescriptionHuman