יחידה:תבנית מידע/אישיות2: הבדלים בין גרסאות בדף

יצירת דף עם התוכן "local Infobox = require('Module:תבנית מידע').Infobox local LocationAndCountry = require('Module:LocationAndCountry') local PropertyLink = require('Modul..."
 
אין תקציר עריכה
 
שורה 3: שורה 3:
local PropertyLink = require('Module:PropertyLink2')
local PropertyLink = require('Module:PropertyLink2')
local ageModule = require('Module:גיל לערכי אישים')
local ageModule = require('Module:גיל לערכי אישים')
local Date = require('Module:תאריך')
local hebrewDateModule = require('Module:תאריך עברי')
local hebrewDateModule = require('Module:תאריך עברי')
local WikidataCrossValidation = require('Module:WikidataCrossValidation')
local WikidataCrossValidation = require('Module:WikidataCrossValidation')
שורה 19: שורה 20:
end
end


local function getDeathLabel(deathCause, entityId)
local function getDeathLabel(deathCause, entityId, gender)
local result=''
local fromWikidata=nil
entityId = entityId or mw.wikibase.getEntityIdForCurrentPage()
entityId = entityId or mw.wikibase.getEntityIdForCurrentPage()
if deathCause == nil and entityId ~= nil then
if ( deathCause == nil or deathCause =='' ) and entityId ~= nil then
local deathCauseWikidata = mw.wikibase.getBestStatements(entityId, 'P1196')
local deathCauseWikidata = mw.wikibase.getBestStatements(entityId, 'P1196')
deathCauseWikidata = deathCauseWikidata and deathCauseWikidata[1] and deathCauseWikidata[1].mainsnak
deathCauseWikidata = deathCauseWikidata and deathCauseWikidata[1] and deathCauseWikidata[1].mainsnak
if deathCauseWikidata then
if deathCauseWikidata then
deathCause = mw.wikibase.renderSnak(deathCauseWikidata)
deathCause = mw.wikibase.renderSnak(deathCauseWikidata)
fromWikidata=true
end
end
end
end
local gender = PropertyLink.getPropertyByOptions( 'P21', entityId )
 
-- Use female form of address also for transgender females
if (gender == "אישה טרנסג'נדרית") then gender = 'נקבה' end
if deathCause and deathCause ~= '' then
if deathCause and deathCause ~= '' then
if deathCause == 'נהרג' or deathCause == 'נהרגה' then
if deathCause == 'נהרג' or deathCause == 'נהרגה' or deathCause == 'מוות בקרב' or deathCause == 'נהרג בקרב' or deathCause == 'נהרגה בקרב' or deathCause == 'תאונה' then
return (gender=='נקבה' and 'נהרגה') or 'נהרג'
return (gender=='נקבה' and 'נהרגה') or 'נהרג'
elseif deathCause == 'נרצח' or deathCause == 'נרצחה' or deathCause == 'רצח' then
elseif deathCause == 'נרצח' or deathCause == 'נרצחה' or deathCause == 'רצח' or deathCause == 'רעל' then
return (gender=='נקבה' and 'נרצחה') or 'נרצח'
return (gender=='נקבה' and 'נרצחה') or 'נרצח'
        elseif deathCause == 'התאבד' or deathCause == 'התאבדה' or deathCause == 'התאבדות' then
    elseif deathCause == 'התאבד' or deathCause == 'התאבדה' or deathCause == 'התאבדות' then
return (gender=='נקבה' and 'התאבדה') or 'התאבד'
return (gender=='נקבה' and 'התאבדה') or 'התאבד'
elseif deathCause == 'הוצא להורג' or deathCause == 'הוצאה להורג' or deathCause == 'עונש מוות' then
elseif deathCause == 'הוצא להורג' or deathCause == 'הוצאה להורג' or deathCause == 'עונש מוות' or deathCause == 'תלייה' then
return 'הוצאה להורג'
return 'הוצאה להורג'
elseif not fromWikidata then result='[[קטגוריה:ערכים עם סיבת מוות שגויה בתבנית]]'
end
end
end
end
return 'פטירה'
return result .. 'פטירה'
end
end
function getEventDetails(generalDate, hebDate, eventPlace, propDate, propPlace, age, usingWikidata, infoObj)
function getEventDetails(generalDate, hebDate, eventPlace, propDate, propPlace, age, usingWikidata, infoObj)
entityId = infoObj.args.entityId or mw.wikibase.getEntityIdForCurrentPage()
entityId = infoObj.args.entityId or mw.wikibase.getEntityIdForCurrentPage()
age = age or ''
age = age or ''
local formattedEvent
local formattedEvent
local placeDate = propDate
if generalDate~=nil and generalDate~='' then
if generalDate~=nil and generalDate~='' then
local success, placeDateParsed  = pcall(Date.newFromWikitext, generalDate)
if success then
placeDate = placeDateParsed
end
formattedEvent = generalDate .. age
formattedEvent = generalDate .. age
if hebDate~=nil and hebDate~='' then  
if hebDate~=nil and hebDate~='' then  
שורה 58: שורה 69:
if (eventPlace == nil or eventPlace == '') and entityId then
if (eventPlace == nil or eventPlace == '') and entityId then
local success, res  = pcall(LocationAndCountry.displayFromParams, propPlace, entityId, propDate , 1)
local success, res  = pcall(LocationAndCountry.displayFromParams, propPlace, entityId, placeDate , 1)
if success and res and #res>0 then
if success and res and #res>0 then
usingWikidata = true
usingWikidata = true
שורה 65: שורה 76:
else
else
local pageNs = mw.title.getCurrentTitle().namespace
local pageNs = mw.title.getCurrentTitle().namespace
if pageNs==0 then
if pageNs==0 and not infoObj.isNonPerson then
local matching = WikidataCrossValidation.crossValidate(eventPlace, propPlace, entityId )
local matching = WikidataCrossValidation.crossValidate(eventPlace, propPlace, entityId )
if matching then
if matching then
שורה 84: שורה 95:
end
end


function addMissingImage(infoObj, birthDate, deathDate)
function addMissingImage(infoObj, birthDate, deathDate, gender)
if infoObj.args.image ~= nil and #infoObj.args.image > 0 then return end  -- there is already image  
if infoObj.args.image ~= nil and #infoObj.args.image > 0 then return end  -- there is already image  
local latestDate = deathDate or birthDate
local latestDate = deathDate or birthDate
שורה 94: שורה 105:
if yearsEstimated>150 then return end  
if yearsEstimated>150 then return end  
if infoObj.args.entityId == nil then
return false -- no wikidata entity
end
local gender = PropertyLink.getPropertyByOptions( 'P21', infoObj.args.entityId )
local frame = mw.getCurrentFrame()
local frame = mw.getCurrentFrame()
infoObj.args.image = frame:expandTemplate{ title = 'אין תמונה', args = { gender, ['יישור'] = 'center' } }
infoObj.args.image = frame:expandTemplate{ title = 'אין תמונה', args = { gender, ['יישור'] = 'center' } }
שורה 106: שורה 112:
local usingWikidata = false
local usingWikidata = false
if infoObj.args.entityId == nil then
if infoObj.args.entityId == nil then
local matching = WikidataCrossValidation.crossValidate(templateArgs[paramName], property, infoObj.args.entityId )
if matching then
table.insert(infoObj.wikidataCats, WikidataCrossValidation.maintainceCategory(matching, property))
end
return false -- no wikidata entity
return false -- no wikidata entity
end
end
שורה 115: שורה 125:
else
else
local pageNs = mw.title.getCurrentTitle().namespace
local pageNs = mw.title.getCurrentTitle().namespace
if pageNs==0 then
if pageNs==0 and not infoObj.isNonPerson then
local matching = WikidataCrossValidation.crossValidate(templateArgs[paramName], property, infoObj.args.entityId )
local matching = WikidataCrossValidation.crossValidate(templateArgs[paramName], property, infoObj.args.entityId )
if matching then
if matching then
שורה 123: שורה 133:
end
end
return usingWikidata
return usingWikidata
end
local function instanceOfViolation(infoObj)
local pageNs = mw.title.getCurrentTitle().namespace
if pageNs~=0 then
return true
end
local wikidataInstanceOf = nil
if infoObj.args.entityId ~= nil then
wikidataInstanceOf = mw.wikibase.getBestStatements(infoObj.args.entityId, 'P31')
wikidataInstanceOf = wikidataInstanceOf and wikidataInstanceOf[1] and wikidataInstanceOf[1].mainsnak
end
if wikidataInstanceOf == nil then
local matching = WikidataCrossValidation.crossValidate('אדם', 'P31', infoObj.args.entityId )
if matching then
mw.logObject(matching)
table.insert(infoObj.wikidataCats, WikidataCrossValidation.maintainceCategory(matching, 'P31'))
end
else
wikidataInstanceOf = wikidataInstanceOf.datavalue and wikidataInstanceOf.datavalue.value and wikidataInstanceOf.datavalue.value.id
if wikidataInstanceOf ~= 'Q5' then
table.insert(infoObj.wikidataCats, '[[קטגוריה: ויקינתונים - תבניות אישיות למופע לא מתאים]]')
return true
end
end
return false
end
end


שורה 132: שורה 170:
local deathLabel = 'פטירה'  
local deathLabel = 'פטירה'  
infoObj.isNonPerson = instanceOfViolation(infoObj)
local wikidataGender = nil
if not infoObj.isNonPerson then
wikidataGender = PropertyLink.getPropertyByOptions( 'P21', infoObj.args.entityId )
if wikidataGender == nil then
table.insert(infoObj.wikidataCats, '[[קטגוריה:אישים חסרי מגדר בוויקינתונים]]')
end
end
-- fill birth/death dates from wikidata is missing
-- fill birth/death dates from wikidata is missing
usingBirthWikidata = fillWikidataParam(templateArgs, 'תאריך לידה', 'P569', infoObj)
usingBirthWikidata = fillWikidataParam(templateArgs, 'תאריך לידה', 'P569', infoObj)
שורה 150: שורה 197:
})
})
usingBirthWikidata = usingBirthWikidata or usingBirthWikidataEvent
usingBirthWikidata = usingBirthWikidata or usingBirthWikidataEvent
else
elseif templateArgs['מקום לידה']~= '-' then
    if templateArgs['מקום לידה']~= '-' and templateArgs['מקום לידה']~= '' and  templateArgs['מקום לידה']~=nil and #templateArgs['מקום לידה']>0 then
fillWikidataParam(templateArgs, 'מקום לידה', 'P19', infoObj)
table.insert(infoObj.templateStructure, 1, {
table.insert(infoObj.templateStructure, 1, {
    label=birthLabel,
label=birthLabel,
    data= templateArgs['מקום לידה']
data= templateArgs['מקום לידה']
})  
})
  end
end
    end
deathLabel = getDeathLabel(templateArgs['סיבת המוות'], infoObj.args.entityId, wikidataGender)
if deathDate~=nil then
if deathDate~=nil then
deathLabel = getDeathLabel(templateArgs['סיבת המוות'], infoObj.args.entityId)
local age =  ageModule.ageCalc(birthDate, deathDate, false, false, true) or ''
local age =  ageModule.ageCalc(birthDate, deathDate, false, false, true) or ''
local deathDetails, usingDeathWikidataEvent = getEventDetails(templateArgs['תאריך פטירה'], templateArgs['תאריך פטירה עברי'], templateArgs['מקום פטירה'], 'P570', 'P20', age, usingDeathWikidata, infoObj)
local deathDetails, usingDeathWikidataEvent = getEventDetails(templateArgs['תאריך פטירה'], templateArgs['תאריך פטירה עברי'], templateArgs['מקום פטירה'], 'P570', 'P20', age, usingDeathWikidata, infoObj)
שורה 168: שורה 214:
})
})
usingDeathWikidata = usingDeathWikidata or usingDeathWikidataEvent
usingDeathWikidata = usingDeathWikidata or usingDeathWikidataEvent
elseif templateArgs['מקום פטירה']~= '-' then
fillWikidataParam(templateArgs, 'מקום פטירה', 'P20', infoObj)
table.insert(infoObj.templateStructure, 2, {
label=deathLabel,
data= templateArgs['מקום פטירה']
})
end
end
שורה 196: שורה 248:


if frame.args['תמונה']~='-' then
if frame.args['תמונה']~='-' then
addMissingImage(infoObj, birthDate, deathDate)
addMissingImage(infoObj, birthDate, deathDate, wikidataGender)
end
end
end
end