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

מ שוחזר מעריכות של קיפודנחש (שיחה) לעריכה האחרונה של Dovno
מ 9 גרסאות של הדף wikipedia:he:יחידה:תבנית_מידע/אישיות יובאו
 
(24 גרסאות ביניים של 6 משתמשים אינן מוצגות)
שורה 20: שורה 20:
end
end


local function getDeathLabel(deathCause, entityId)
local function getDeathLabel(deathCause, entityId, gender)
local result=''
local result=''
local fromWikidata=nil
local fromWikidata=nil
שורה 32: שורה 32:
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 == 'נהרגה' or deathCause == 'מוות בקרב' or deathCause == 'נהרג בקרב' or deathCause == 'נהרגה בקרב' or deathCause == 'תאונה' then
if deathCause == 'נהרג' or 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 == 'רצח' or deathCause == 'רעל' then
elseif deathCause == 'נעדר' or deathCause == 'נעדרת' then
return (gender=='נקבה' and 'נעדרת') or 'נעדר'
elseif 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 == 'התאבדות' then
שורה 77: שורה 75:
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
שורה 96: שורה 94:
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
שורה 106: שורה 104:
if yearsEstimated>150 then return end  
if yearsEstimated>150 then return end  
local gender = nil
if infoObj.args.entityId ~= nil then
gender = PropertyLink.getPropertyByOptions( 'P21', infoObj.args.entityId )
end
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, ['יישור'] = 'מרכז' } }
end
end


שורה 118: שורה 111:
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
שורה 127: שורה 124:
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
שורה 135: שורה 132:
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


שורה 144: שורה 169:
local deathLabel = 'פטירה'  
local deathLabel = 'פטירה'  
-- fill birth/death dates from wikidata is missing
infoObj.isNonPerson = instanceOfViolation(infoObj)
usingBirthWikidata = fillWikidataParam(templateArgs, 'תאריך לידה', 'P569', infoObj)
usingDeathWikidata = fillWikidataParam(templateArgs, 'תאריך פטירה', 'P570', infoObj)
local wikidataGender = nil
if not infoObj.isNonPerson then
wikidataGender = PropertyLink.getItem( 'P21', infoObj.args.entityId )
if wikidataGender == nil then
table.insert(infoObj.wikidataCats, '[[קטגוריה:אישים חסרי מגדר בוויקינתונים]]')
else
if (wikidataGender == "Q6581097") then -- male
wikidataGender = 'זכר'
elseif (wikidataGender == "Q2449503") then -- transgender male
wikidataGender = 'זכר'
elseif (wikidataGender == "Q15145778") then -- cisgender male
wikidataGender = 'זכר'
elseif (wikidataGender == "Q6581072") then -- female
wikidataGender = 'נקבה'
elseif (wikidataGender == "Q1052281") then -- transgender female
wikidataGender = 'נקבה'
elseif (wikidataGender == "Q15145779") then -- cisgender female
wikidataGender = 'נקבה'
elseif wikidataGender == 'Q1097630' -- intersex
or wikidataGender == 'Q48270' -- non binary
then wikidataGender = '' -- עד שתחליטו
end
end
end
-- fill birth/death dates from wikidata if missing and the person is not a human biblical figure
if PropertyLink.getItem( 'P31', infoObj.args.entityId )~="Q20643955" then
usingBirthWikidata = fillWikidataParam(templateArgs, 'תאריך לידה', 'P569', infoObj)
usingDeathWikidata = fillWikidataParam(templateArgs, 'תאריך פטירה', 'P570', infoObj)
end
local birthDate = getSpeculativeDate(templateArgs['תאריך לידה'], templateArgs['תאריך לידה עברי'])
local birthDate = getSpeculativeDate(templateArgs['תאריך לידה'], templateArgs['תאריך לידה עברי'])
שורה 154: שורה 207:
local age = nil
local age = nil
if deathDate==nil then
if deathDate==nil then
age = ageModule.ageCalc(birthDate, nil, true, false, true) or ''
age = ageModule.ageCalc(birthDate, nil, true, false, true, nil, wikidataGender) or ''
end
end
local birthDetails, usingBirthWikidataEvent = getEventDetails(templateArgs['תאריך לידה'], templateArgs['תאריך לידה עברי'], templateArgs['מקום לידה'], 'P569', 'P19', age, usingBirthWikidata, infoObj)
local birthDetails, usingBirthWikidataEvent = getEventDetails(templateArgs['תאריך לידה'], templateArgs['תאריך לידה עברי'], templateArgs['מקום לידה'], 'P569', 'P19', age, usingBirthWikidata, infoObj)
table.insert(infoObj.templateStructure, 1, {
table.insert(infoObj.templateStructure, 1, {
label='לידה',
label=birthLabel,
data=birthDetails
data=birthDetails
})
})
שורה 164: שורה 217:
elseif templateArgs['מקום לידה']~= '-' then
elseif templateArgs['מקום לידה']~= '-' then
fillWikidataParam(templateArgs, 'מקום לידה', 'P19', infoObj)
fillWikidataParam(templateArgs, 'מקום לידה', 'P19', infoObj)
table.insert(infoObj.templateStructure, 1, {
if  templateArgs['מקום לידה']~= nil and templateArgs['מקום לידה']~= '' then -- only if we fill the parameter eventually - add to template
label=birthLabel,
table.insert(infoObj.templateStructure, 1, {
data= templateArgs['מקום לידה']
label=birthLabel,
})
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)
שורה 181: שורה 236:
elseif templateArgs['מקום פטירה']~= '-' then
elseif templateArgs['מקום פטירה']~= '-' then
fillWikidataParam(templateArgs, 'מקום פטירה', 'P20', infoObj)
fillWikidataParam(templateArgs, 'מקום פטירה', 'P20', infoObj)
table.insert(infoObj.templateStructure, 2, {
if templateArgs['מקום פטירה']~= nil and templateArgs['מקום פטירה']~= '' then -- only if we fill the parameter eventually - add to template
label=deathLabel,
table.insert(infoObj.templateStructure, 2, {
data= templateArgs['מקום פטירה']
label=deathLabel,
})
data= templateArgs['מקום פטירה']
})
end
end
end
שורה 213: שורה 270:


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