יחידה:גיל לערכי אישים: הבדלים בין גרסאות בדף

מ טיפול בפעוטות
מ ריבוי אפשרויות
שורה 31: שורה 31:


function consistentWithWikidata(localDate, wikidataClaim)
function consistentWithWikidata(localDate, wikidataClaim)
wikidataClaim = wikidataClaim and wikidataClaim[1] and  wikidataClaim[1].mainsnak and wikidataClaim[1].mainsnak.datavalue and wikidataClaim[1].mainsnak.datavalue.value
local possibleDate, possibleDateValue, isConsistent
if not wikidataClaim then
if not wikidataClaim then
return true
return true
end
end
local iswikidataValid, wikidataDate = pcall(dateParser.newFromWikidataValue, wikidataClaim)
isConsistent = true
if iswikidataValid and localDate.calendar == wikidataDate.calendar then
for i,possibleDate in ipairs(wikidataClaim) do
if (localDate.year ~= wikidataDate.year and wikidataClaim.precision>=dateParser.PRECISION.YEAR) or  
if possibleDate.mainsnak and possibleDate.mainsnak.datavalue and possibleDate.mainsnak.datavalue.value then
  (localDate.month ~= wikidataDate.month and wikidataClaim.precision>=dateParser.PRECISION.MONTH) or  
possibleDateValue = possibleDate.mainsnak.datavalue.value
  (localDate.day ~= wikidataDate.day and wikidataClaim.precision>=dateParser.PRECISION.DAY)  then
local iswikidataValid, wikidataDate = pcall(dateParser.newFromWikidataValue, possibleDateValue)
return false
if iswikidataValid and localDate.calendar == wikidataDate.calendar then
end
if (localDate.year ~= wikidataDate.year and possibleDateValue.precision>=dateParser.PRECISION.YEAR) or  
end
  (localDate.month ~= wikidataDate.month and possibleDateValue.precision>=dateParser.PRECISION.MONTH) or  
  return true
  (localDate.day ~= wikidataDate.day and possibleDateValue.precision>=dateParser.PRECISION.DAY)  then
isConsistent = false
else
isConsistent = true
break
end
end
end
end
 
  return isConsistent
end
end


שורה 84: שורה 94:
end
end
if wikidataBirth and wikidataBirth[1] and wikidataBirth[1].mainsnak  then
if wikidataBirth and wikidataBirth[1] and wikidataBirth[1].mainsnak  then
--local iswikidataValid, wikidataBirthDate = pcall(dateParser.newFromWikidataValue, wikidataBirth[1].mainsnak)
if not consistentWithWikidata(BirthDate, wikidataBirth) then
if not consistentWithWikidata(BirthDate, wikidataBirth) then
table.insert(warnings, '[[קטגוריה:דפים עם שנות חיים שלא תואמים את ויקינתונים]]')
table.insert(warnings, '[[קטגוריה:דפים עם שנות חיים שלא תואמים את ויקינתונים]]')