Перейти к содержанию

Модуль:AutoDescriptionHuman

Материал из Викиновостей, свободного источника новостей
Документация
--[[
------------------------------------------
--             AutoDescriptionHuman
-- Модуль для заполнения людей. 
------------------------------------------
--]]

local Dates = require("Module:Dates")
local Declension = require("Module:Declension")
local Langs = require("Module:Langs")
local MathTonumber = require("Module:Math/tonumber")
local ReturnGendered = require("Module:ReturnGendered")
local SerializeTable = require("Module:SerializeTable")
local Math = require("Module:Math")

local AutoDescriptionHuman={}

-- Нам необходимо сформировать и вернуть три переменных
local description = "" -- уточнение (то, что в скобочках после имени, например, на языке оригинала, годы жизни и т.п.)
local details = "" -- строка описания
local categories = "[[Категория:Люди по алфавиту]]" -- категории

-- Промежуточный масив сущностей, в который помещаются результаты парсинга перед формированием описания
local entitiesArray = {P21 = "", P27 = "", P39 = "", P69 = "", P101 = {}, P101Q ="", 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 .. "[[Категория:Страницы с ошибками в модуле]][[Категория:Страницы с ошибками в модуле AutoDescriptionHuman]]"
  if errCodeParsing then categories = categories .. "[[Категория:Страницы с ошибкой: " .. errCodeParsing .. "]]" end
  if errCodeForming then categories = categories .. "[[Категория:Страницы с ошибкой: " .. 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"] .. " года]]"	
   elseif (entitiesArray["P569"] ~= "") then details = details .. "род. [[" .. entitiesArray["P569"] .. " года]]"	
   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"] .. " года]]" 	
   elseif (entitiesArray["P570"] ~= "") then details = details .. "ум. [[" .. entitiesArray["P570"] .. " года]]" 
   end
   if(entitiesArray["placeOfDeath"] ~= "") then  details = details .. ",  [[" .. entitiesArray["placeOfDeath"] .. "]]" end
   if(entitiesArray["countryOfDeath"] ~= "") then  details = details .. ", [[" .. entitiesArray["countryOfDeath"] .. "]]" end 
   details = details .. ")"
 end

 if (entitiesArray["P21"] == "мужской пол") then 
  categories = categories .. "[[Категория:Мужчины по алфавиту]]" 
 elseif (entitiesArray["P21"] == "женский пол") then
  categories = categories .. "[[Категория:Женщины по алфавиту]]"
 elseif (entitiesArray["P21"] == "транс-мужчина") then
  categories = categories .. "[[Категория:Транс-мужчины по алфавиту]]"
 elseif (entitiesArray["P21"] == "транс-женщина") then
  categories = categories .. "[[Категория:Транс-женщины по алфавиту]]"
 elseif (entitiesArray["P21"] == "интерсекс") then
  categories = categories .. "[[Категория:Интерсексуалы по алфавиту]]"
 elseif (entitiesArray["P21"] == "гендерфлюид") then
  categories = categories .. "[[Категория:Гендерфлюиды по алфавиту]]"
 elseif (entitiesArray["P21"] == "небинарный пол") then
  categories = categories .. "[[Категория:Небинарный пол по алфавиту]]"
 elseif (entitiesArray["P21"] == "") then
  categories = categories .. "[[Категория:Пол не установлен]]"
 else
  categories = categories .. "[[Категория:Пол не определён]]"
 end
 
 if(entitiesArray["P734"] == nil) then
  categories = categories .. "[[Категория:Фамилия не установлена (nil)]]"
 elseif(entitiesArray["P734"] == "") then
  categories = categories .. "[[Категория:Фамилия не установлена (empty)]]"
 else 
  categories = categories .. "[[Категория:"..entitiesArray["P734"].." (однофамильцы по алфавиту)]]"
 end
 
 if(entitiesArray["P735"] == nil) then
  categories = categories .. "[[Категория:Имя не установлено (nil)]]"
 elseif(entitiesArray["P735"] == "") then
  categories = categories .. "[[Категория:Имя не установлено (empty)]]"
 else 
  categories = categories .. "[[Категория:"..entitiesArray["P735"].." (тёзки по алфавиту)]]"
 end
 
 if (entitiesArray["occupation"][1] ~= "") then
 	for ki, vi in pairs (entitiesArray.occupation) do
     	if(ki=="1") then 
         if(entitiesArray["P21"] == "мужской пол") 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"] == "мужской пол") 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["P2021"] ~= "") then description = description .. "[[Число Эрдёша]]: " .. entitiesArray["P2021"] .. ". " end
 if (entitiesArray["P101"][1] ~= "" and string.find(entitiesArray.P101Q, "Q")) then
 	description = description .. " Занимался исследованиями в области: "
 	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>Членство в организациях: " -- ReturnGendered.launch("Участник", entitiesArray["P21"], 2) .. " организаций: "
   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>Образование: "
 	for ki, vi in pairs (entitiesArray.edu) do
 		description = description .. "[[" .. vi ..  "]]"  
 		if(entitiesArray.eduStart[i] ~= "None") then description = description .. " с " .. "[[" .. entitiesArray.eduStart[i] .. " год]]а" end
 		if(entitiesArray.eduEnd[i] ~= "None") then description = description .. " по ".. "[[" .. entitiesArray.eduEnd[i] .. " год]]" 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 .. "Учёные степени: "
 	else description = description .. "Учёная степень: " 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] .. " год]]"
 				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>Место работы: "
 	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("Испытал", entitiesArray["P21"], 3)
   if (rg ~= nil and rg ~= "") then
   	description = description .. rg .. " влияние: " 
    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 .. "Научный руководитель: "
 	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 .. "Аспиранты: "
    else description = description .. "Аспирант: " 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 .. "Студенты: "
    else description = description .. "Студент: " 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 .. "Учитель: "
 	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>[[Мать]]: [[" .. entitiesArray["moth"] .. "]]. " end	
 if(entitiesArray["father"] ~= "") then 	description = description .. "[[Отец]]: [[" .. 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 .. "Жанры: "
    else description = description .. "Жанр: " 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 .. "Музыкальные инструменты: "
    else description = description .. "Музыкальный инструмент: " 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>Места жительства: "
    else description = description .. "<br>Место жительства: " end
 	for k, v in pairs (entitiesArray.residence) do
 		description = description .. "[[" .. v ..  "]]"
 		if(entitiesArray.residenceSt[k] ~= "NoNe") then description = description .. " с " .. "[[" .. entitiesArray.residenceSt[k] .. " год]]а" end
 		if(entitiesArray.residenceEnd[k] ~= "NoNe") then description = description .. " по ".. "[[" .. entitiesArray.residenceEnd[k] .. " год]]" 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>Места активности: "
    else description = description .. "<br>Место активности: " 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 .. "Сиблинги: "
    else description = description .. "Сиблинг: " 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 .. "Участие в: "
 	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>Награды и премии: "
 	for k, v in pairs (entitiesArray.award) do
 		description = description .. "[[" .. v ..  "]]"
 		if(entitiesArray.awardPIT[k]~="") then description = description .. " ([[" .. entitiesArray.awardPIT[k] .. " год]]" end
 		if(entitiesArray.awardTW[k]~="") then description = description .. "; совместно с:" .. entitiesArray.awardTW[k] end
 		if(entitiesArray.awardPM[k]~="") then description = description .. "; призовой фонд: " .. 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>Выдающиеся работы: "  
 	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>Занимаемые должности: "
 	else description = description .. "<br>Занимаемая должность: " end	
    for k, v in pairs (entitiesArray.positionHeld) do
    	description = description .. v 
    	if(entitiesArray.positionHeldStart[k] ~= "None") then description = description .. " с [[" .. entitiesArray.positionHeldStart[k] .. " год]]а" end
    	if(entitiesArray.positionHeldEnd[k] ~= "None") then description = description .. " по [[" .. entitiesArray.positionHeldEnd[k] .. " год]]" 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 .. " после [[" .. entitiesArray.positionHeldReplace[k] .. "]]" end
    	if(entitiesArray.positionHeldReplaceBy[k] ~= "None") then description = description .. " перед [[" .. 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 .. "[[Категория:Люди:" .. vi .. "]]"
 	end	
 end	
 if(entitiesArray["P569"] ~= "") then 
 	if(entitiesArray["dayB"] ~= nil and (string.find(entitiesArray["monthB"], "значение неизвестно") == nil) and entitiesArray["dayB"] ~= "" and entitiesArray["monthB"] ~= "") then categories = categories .. " [[Категория:Родившиеся " .. entitiesArray["P569"] .. " года]]"
 	elseif (entitiesArray["monthB"] ~= "") then categories = categories .. " [[Категория:Родившиеся в " .. Declension.declineWord(entitiesArray.monthB, 6) .. " " .. entitiesArray.yearB .. " года]]" end
 end
 if(entitiesArray["placeOfBirth"] ~= "") then 
 	if (Declension.declineWord(entitiesArray["placeOfBirth"], 6) == "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Категория:Города без склонения]]" .. "[[Категория:Место рождения: " .. entitiesArray["placeOfBirth"] .. "]]"
 	else categories = categories .. " [[Категория:Родившиеся в " .. Declension.declineWord(entitiesArray["placeOfBirth"], 6).. "]]" end
 end 
 if(entitiesArray["countryOfBirth"] ~= "") then 
 	if (Declension.declineWord(entitiesArray["countryOfBirth"], 6) == "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Категория:Страны без склонения]]".. "[[Категория:Место рождения: " .. entitiesArray["countryOfBirth"] .. "]]"
 	elseif (entitiesArray["countryOfBirth"] == "Франция") then categories = categories .. " [[Категория:Родившиеся во " .. Declension.declineWord(entitiesArray["countryOfBirth"], 6).. "]]"
 	else categories = categories .. " [[Категория:Родившиеся в " .. Declension.declineWord(entitiesArray["countryOfBirth"], 6).. "]]" 
 	end
 end 
 if(entitiesArray["dayB"] ~= "" and entitiesArray["dayB"] ~= nil and string.find(entitiesArray["monthB"], "значение неизвестно") == nil) then categories = categories .. " [[Категория:Родившиеся " .. entitiesArray["dayB"] .. " " .. entitiesArray["monthB"] .. "]]" end 
 if(entitiesArray["yearB"] ~= "" and entitiesArray["yearB"] ~= nil) then categories = categories .. " [[Категория:Родившиеся в " .. entitiesArray["yearB"] .. " году]]" end 
 if(entitiesArray["P570"] ~= "") then categories = categories .. " [[Категория:Умершие " .. entitiesArray["P570"] .. " года]]" end
 if(entitiesArray["placeOfDeath"] ~= "") then 
 	if (Declension.declineWord(entitiesArray["placeOfDeath"], 6) == "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Категория:Города без склонения]]" .. "[[Категория:Место смерти: " .. entitiesArray["placeOfDeath"] .. "]]"
 	else categories = categories .. " [[Категория:Умершие в " .. Declension.declineWord(entitiesArray["placeOfDeath"], 6).. "]]" end
 end 
 if(entitiesArray["countryOfDeath"] ~= "") then 
 	if (Declension.declineWord(entitiesArray["countryOfDeath"], 6) == "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Категория:Страны без склонения]]" .. "[[Категория:Место смерти: " .. entitiesArray["countryOfDeath"] .. "]]"
	elseif (entitiesArray["countryOfDeath"] == "Франция") then categories = categories .. " [[Категория:Умершие во " .. Declension.declineWord(entitiesArray["countryOfDeath"], 6).. "]]"
	else categories = categories .. " [[Категория:Умершие в " .. Declension.declineWord(entitiesArray["countryOfDeath"], 6).. "]]" end
 end 
 if(entitiesArray["dayD"] ~= "" and entitiesArray["dayD"] ~= nil) then categories = categories .. " [[Категория:Умершие " .. entitiesArray["dayD"] .. " " .. entitiesArray["monthD"] .. "]]" end 
 if(entitiesArray["yearD"] ~= "" and entitiesArray["yearD"] ~= nil) then categories = categories .. " [[Категория:Умершие в " .. entitiesArray["yearD"] .. " году]]" end 
 if (entitiesArray["occupation"][1] ~= "") then 
 	local p=false
 	local q=false
 	for ki, vi in pairs (entitiesArray.occupation) do
 	 if(entitiesArray["P21"] ~= "мужской пол" and Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) ~= "Logical error Declension.declineWord(arg): word not found") then
 	  categories = categories .. "[[Категория:" .. Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) .. " по алфавиту]]"  	
 	 elseif(Declension.declineWord(vi, 7) ~= "Logical error Declension.declineWord(arg): word not found") then
 	  categories = categories .. "[[Категория:" .. Declension.declineWord(vi, 7) .. " по алфавиту]]" 
 	 else
 	   p=true 
 	   categories = categories .. "[[Категория:Род занятий: " .. vi .. " ]]"
 	 end
 		
 	    if (Declension.declineWord(entitiesArray["countryOfBirth"], 6) == "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"] ~= "мужской пол" 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 .. " [[Категория:" .. Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) .. " " .. Declension.declineWord(entitiesArray["countryOfBirth"], 2).. "]]" 
 	    	else categories = categories .. " [[Категория:" .. Declension.declineWord(vi, 7) .. " " .. Declension.declineWord(entitiesArray["countryOfBirth"], 2).. "]]" 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"] ~= "мужской пол" 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 .. "[[Категория:" .. Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) .. " " .. Math.roman((yC:match('%d%d') + "1")) .. " века]]"
 	        		else categories = categories .. "[[Категория:" .. Declension.declineWord(vi, 7) .. " " .. Math.roman((yC:match('%d%d') + "1")) .. " века]]" end 
 	        	elseif (#yC==3) then
      	    		if(entitiesArray["P21"] ~= "мужской пол" 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 .. "[[Категория:" .. Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) .. " " .. Math.roman((yC:match('%d') + "1")) .. " века]]"
 	        		else categories = categories .. "[[Категория:" .. Declension.declineWord(vi, 7) .. " " .. Math.roman((yC:match('%d') + "1")) .. " века]]" end
 	        	else	
      	    		if(entitiesArray["P21"] ~= "мужской пол" 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 .. "[[Категория:" .. Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) .. " " .. Math.roman(("1")) .. " века]]"
 	        		else categories = categories .. "[[Категория:" .. Declension.declineWord(vi, 7) .. " " .. Math.roman(("1")) .. " века]]" 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"] ~= "мужской пол" 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 .. "[[Категория:" .. Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) .. " " .. Math.roman((yC:match('%d%d') + "1")) .. " века]]"
 	        		else categories = categories .. "[[Категория:" .. Declension.declineWord(vi, 7) .. " " .. Math.roman((yC:match('%d%d') + "1")) .. " века]]" end 
 	        	elseif (#yC==3) then
      	    		if(entitiesArray["P21"] ~= "мужской пол" 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 .. "[[Категория:" .. Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) .. " " .. Math.roman((yC:match('%d') + "1")) .. " века]]"
 	        		else categories = categories .. "[[Категория:" .. Declension.declineWord(vi, 7) .. " " .. Math.roman((yC:match('%d') + "1")) .. " века]]" end
 	        	else	
      	    		if(entitiesArray["P21"] ~= "мужской пол" 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 .. "[[Категория:" .. Declension.declineWord(ReturnGendered.launch(vi, entitiesArray["P21"], 2), 7) .. " " .. Math.roman(("1")) .. " века]]"
 	        		else categories = categories .. "[[Категория:" .. Declension.declineWord(vi, 7) .. " " .. Math.roman(("1")) .. " века]]" end
 	        	end	
 	    	end
 	    end  
 	end	
 	if (p == true) then categories = categories .. "[[Категория:Профессии без склонения]]" end
 	if (q == true) then categories = categories .. "[[Категория:Страны без склонения]]" 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 .. "[[Категория:Род занятий: " .. vi .. " ]]"  
 		else categories = categories .. "[[Категория:" .. Declension.declineWord(vi, 7) .. " по алфавиту]]" end
 	    if (Declension.declineWord(entitiesArray["countryOfBirth"], 6) == "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 .. " [[Категория:" .. Declension.declineWord(vi, 7) .. " " .. Declension.declineWord(entitiesArray["countryOfBirth"], 2).. "]]" end
 	    if(entitiesArray.yearB ~= "" and Declension.declineWord(vi, 7) ~= "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Категория:" .. Declension.declineWord(vi, 7) .. " " .. Math.roman((entitiesArray.yearB:match('%d%d') + "1")) .. " века]]" end
 	    if(entitiesArray.yearD ~= "" and Declension.declineWord(vi, 7) ~= "Logical error Declension.declineWord(arg): word not found") then categories = categories .. "[[Категория:" .. Declension.declineWord(vi, 7) .. " " .. Math.roman((entitiesArray.yearD:match('%d%d') + "1")) .. " века]]" end 
     end
   end
   if (p == true) then categories = categories .. "[[Категория:Профессии без склонения]]" end
   if (q == true) then categories = categories .. "[[Категория:Страны без склонения]]" 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 .. "[[Категория:" .. vi .. " (участники)]]"
   	else categories = categories .. "[[Категория: Участники " .. Declension.declineWord(vi, 2) .. "]]" end
   end
   if (p == true) then categories = categories .. "[[Категория:Организации без склонения]]" 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 .. "[[Категория:" .. vi .. " (выпускники)]]"
   	else categories = categories .. "[[Категория: Выпускники " .. Declension.declineWord(vi, 2) .. "]]" end
   end
   if (p == true) then categories = categories .. "[[Категория:Образовательные учреждения без склонения]]" 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 .. "[[Категория:Место жительства: " .. vi .. " ]]"
   	else categories = categories .. "[[Категория: Жители " .. Declension.declineWord(vi, 2) .. "]]" end
   end
   if (p == true) then categories = categories .. "[[Категория:Города без склонения]]" 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 .. "[[Категория:" .. vi .. " (лауреаты)]]"
   	else categories = categories .. "[[Категория: Лауреаты " .. Declension.declineWord(vi, 2) .. "]]" end
   end
   if (p == true) then categories = categories .. "[[Категория:Награды без склонения]]" 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 .. "[[Категория:" .. vi .. " (участники)]]"
   	else categories = categories .. "[[Категория: Участники " .. Declension.declineWord(vi, 2) .. "]]" end
   end
   if (p == true) then categories = categories .. "[[Категория:Мероприятия без склонения]]" 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 == "мужской пол") then male="1"
 	elseif (values == "женский пол") 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] == "род занятий" or entitiesArray["upOccupation"][i] == "личность") then entitiesArray["upOccupation"][i]="bin" end
	if (entitiesArray["upOccupation"][i] == "игрок") then entitiesArray["upOccupation"][i]="спортсмен" 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
   entitiesArray.employer[i]= mw.wikibase.getLabel(vi['mainsnak']['datavalue']['value']['id']) 
   entitiesArray.P108Q=vi['mainsnak']['datavalue']['value']['id']
   i=i+1
 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, '[^а-я]', '' )
 	if(string.find(values, "февраля")) then entitiesArray["monthB"]="февраля" 
 	elseif (string.find(values, "ноября")) then  entitiesArray["monthB"]="ноября" 
 	elseif (string.find(values, "сентября")) then  entitiesArray["monthB"]="сентября" 
 	elseif (string.find(values, "апреля")) then  entitiesArray["monthB"]="апреля" 
 	elseif (string.find(values, "июля")) then  entitiesArray["monthB"]="июля" 
 	elseif (string.find(values, "июль")) then  entitiesArray["monthB"]="июль" 
 	elseif (string.find(values, "марта")) then  entitiesArray["monthB"]="марта"
 	elseif (string.find(values, "июня")) then  entitiesArray["monthB"]="июня" 
 	elseif (string.find(values, "декабря")) then  entitiesArray["monthB"]="декабря" 
 	elseif (string.find(values, "января")) then  entitiesArray["monthB"]="января" 
 	elseif (string.find(values, "августа")) then  entitiesArray["monthB"]="августа" 
 	elseif (string.find(values, "октября")) then  entitiesArray["monthB"]="октября" 
 	elseif (string.find(values, "значение неизвестно")) 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	
 	return values   
 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, '[^а-я]', '' )
 	if(string.find(values, "февраля")) then entitiesArray["monthD"]="февраля"  
 	elseif (string.find(values, "ноября")) then  entitiesArray["monthD"]="ноября" 
 	elseif (string.find(values, "сентября")) then  entitiesArray["monthD"]="сентября" 
 	elseif (string.find(values, "апреля")) then  entitiesArray["monthD"]="апреля" 
 	elseif (string.find(values, "июля")) then  entitiesArray["monthD"]="июля" 
 	elseif (string.find(values, "марта")) then  entitiesArray["monthD"]="марта"
 	elseif (string.find(values, "июня")) then  entitiesArray["monthD"]="июня" 
 	elseif (string.find(values, "декабря")) then  entitiesArray["monthD"]="декабря" 
 	elseif (string.find(values, "января")) then  entitiesArray["monthD"]="января" 
 	elseif (string.find(values, "августа")) then  entitiesArray["monthD"]="августа"
 	elseif (string.find(values, "октября")) then  entitiesArray["monthD"]="октября" 
	elseif (string.find(values, "значение неизвестно")) 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, "ru")
      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, "ru")
      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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy