Modul:WikidataUtils/Biography

De la Wikipedia, enciclopedia liberă

Documentația acestui modul poate fi creată la Modul:WikidataUtils/Biography/doc

local Wikidata = require('Modul:Wikidata')
local p = {}

local function isDead(qId) 
	local deathDateClaims = Wikidata.findBestClaimsForProperty(qId, 'P570')
	if deathDateClaims then for _,eachDeathDateClaim in ipairs(deathDateClaims) do
		if Wikidata.isClaimTrue(eachDeathDateClaim) and eachDeathDateClaim.mainsnak.snaktype ~= 'novalue'
			then
				return true
			end
	end end
	return false
end
p.isDead = isDead

local function isFemale(qId)
	local genders = Wikidata.findBestClaimsForProperty(qId, 'P21')
	local feminineIds = { 6581072, 1052281, 43445 }
	
	if genders then for genderIdx,eachGender in ipairs(genders) do
		if Wikidata.hasValueSnak(eachGender) and Wikidata.isClaimTrue(eachGender) then for _,eachFemId in ipairs(feminineIds) do
			if eachFemId == eachGender.mainsnak.datavalue.value['numeric-id'] then return true end
		end end
	end end
	return false
end
p.isFemale = isFemale
return p