Направо към съдържанието

Модул:AutoDescriptionHuman

От Уикиновини

Документация за този модул може да бъде създадена на Модул:AutoDescriptionHuman/doc

--[[
------------------------------------------
--             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 = "", 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)
	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["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 .. "]]" .. ", "
     			elseif (ReturnGendered.launch(vi, entitiesArray["P21"], 2) ~= "") then description = description ..  "[[" .. ReturnGendered.launch(vi, entitiesArray["P21"], 2) .. "]]" .. ", "  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
   description = description .. ReturnGendered.launch("Изпитал", entitiesArray["P21"], 3) .. " влияние: " 
   for ki, vi in pairs (entitiesArray.influencedBy) do
  	description = description .. "[[" .. vi ..  "]], "
   end	
   description=description:sub(1, #description - 2)
   description = description .. ". "
 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 .. "Cиблинги: "
    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
		q = vi['mainsnak']['datavalue']['value']['id']
	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]['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)) then entitiesArray.eduStart[i]=MathTonumber.integerModule(vi['qualifiers']['P580'][1]['datavalue']['value']['time'])
    		else entitiesArray.eduStart[i]="None" end
    		if((vi['qualifiers']['P582'] ~= 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) then entitiesArray.awardPIT[k] = MathTonumber.integerModule(v['qualifiers']['P585'][1]['datavalue']['value']['time']) end	
    	if(v['qualifiers']['P2121'] ~= 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) then entitiesArray.residenceEnd[i]=MathTonumber.integerModule(v['qualifiers']['P582'][1]['datavalue']['value']['time']) 
  		else entitiesArray.residenceEnd[i]="NoNe" end
  		if(v['qualifiers']['P580'] ~= 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.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