ሞድዩል:Wikidata/Education formats
Appearance
Documentation for this module may be created at ሞድዩል:Wikidata/Education formats/doc
local p = {}
-- Functions of other modules
local moduleTables = require('Module:Tables')
local tableElement = moduleTables.element
local moduleWikidata = require('Module:Wikidata')
local formatIdEntityWikidata = moduleWikidata.formatIdEntity
local moduleWikidataFormats = require('Module:Wikidata/Formats')
local toLink = moduleWikidataFormats.toLink
local getData = moduleWikidataFormats.getData
local formatPeriodWikidata = moduleWikidataFormats.periodFormat
local degrees = {
['Q163727'] = {abbreviation = 'ዲግሪ', link = 'መዓርግ ዲግሪ'}, -- Bachelor
['Q1765120'] = {abbreviation = 'B.A.', link = 'Bachelor of Arts'},
['Q2878277'] = {abbreviation = 'B.F.A.', link = 'Bachelor of Fine Arts'},
['Q798137'] = {abbreviation = 'B.L.', link = 'Bachelor of Laws'},
['Q787674'] = {abbreviation = 'B.S.', link = 'Bachelor of Science'},
['Q749020'] = {abbreviation = 'ዲግሪ', link = 'ዲግሪ'},
['Q691532'] = {abbreviation = 'ዲግሪ ሕጊ', link = 'ዲግሪ ሕጊ'},
['Q183816'] = {abbreviation = 'ማስተር', link = 'ማስተር'},
['Q2091008'] = {abbreviation = 'M.A.', link = 'Master of Arts'},
['Q191701'] = {abbreviation = 'M.B.A.', link = 'ማስተር ምምሕዳር ንግዲ'},
['Q4175466'] = {abbreviation = 'M.F.A.', link = 'ማስተር ጽቡቕ ስነ ጥበብ'},
['Q950900'] = {abbreviation = 'M.S.', link = 'Master of Science'},
['Q849697'] = {abbreviation = 'ዶ/ር', link = 'ዶክተርነት'},
['Q4618975'] = {abbreviation = 'ዶ/ር', link = 'ዶክተርነት'}, -- doctor
['Q3033550'] = {abbreviation = 'ዶ/ር', link = 'ዶክተርነት (ፈረንሳ)'},
['Q959320'] = {abbreviation = 'Doc. of Law', link = 'Doctor of Law'},
['Q1540185'] = {abbreviation = 'J.D.', link = 'Juris Doctor'},
['Q6518699'] = {abbreviation = 'L.L.D.', link = 'LLD'},
['Q913404'] = {abbreviation = 'M.D.', link = 'ዶክተር ኣብ ሕክምና'},
['Q752297'] = {abbreviation = 'Ph.D.',link = 'Philosophiæ doctor'},
}
local specialties = {
['Q222749'] = {label = 'ተዋስኦ', link = 'ተዋስኦ'},
['Q12271'] = {label = 'ስነ ህንጻ', link = 'ስነ ህንጻ'},
['Q21198'] = {label = 'ስነ ፍልጠት ኮምፕዩተር', link = 'ስነ ፍልጠት ኮምፕዩተር'},
['Q7748'] = {label = 'መሰል', link = 'መሰል'},
['Q4932206'] = {label = 'ስነ ሕጊ', link = 'ስነ ሕጊ'},
['Q382995'] = {label = 'ስነ ፍልጠት ሕጊ', link = 'ስነ ፍልጠት ሕጊ'},
['Q8134'] = {label = 'ስነ ቑጠባ', link = 'ስነ ቑጠባ'},
['Q5891'] = {label = 'ፍልስፍና', link = 'ፍልስፍና'},
['Q413'] = {label = 'ፊዚክስ', link = 'ፊዚክስ'},
['Q309'] = {label = 'ታሪኽ', link = 'ታሪኽ'},
['Q395'] = {label = 'ሕሳብ', link = 'ሕሳብ'},
['Q11190'] = {label = 'ሕክምና', link = 'ሕክምና'},
['Q11030'] = {label = 'ጋዜጠኝነት', link = 'ጋዜጠኝነት'},
['Q36442'] = {label = 'ፖለቲካዊ ስነ ፍልጠት', link = 'ፖለቲካዊ ስነ ፍልጠት'},
['Q9418'] = {label = 'ስነ ኣእምሮ', link = 'ስነ ኣእምሮ'},
['Q2329'] = {label = 'ስነ ቀመም', link = 'ስነ ቀመም'},
['Q21201'] = {label = 'ስነ ማሕበረሰብ', link = 'ስነ ማሕበረሰብ'},
['Q34178'] = {label = 'ስነ መለኮት', link = 'ስነ መለኮት'},
}
function p.formatEducatedIn(value, options, frame, qualifyings)
-- A function that returns for a place of education, such as Harvard University.
--
-- Internal functions
--
function getDegree(degreeId, options)
if not degreeId then
return
end
local degree = degrees[degreeId]
if degree then
return toLink(degree.link, degree.abbreviation, degreeId,options)
else
-- In case the degree is not one of the degrees of the internal table
return formatIdEntityWikidata(degreeId, options)
end
end
function getSpecialization(specialtyId, options)
if not specialtyId then
return
end
local specialty = specialties[specialtyId]
if specialty then
return toLink(specialty.link, specialty.label, specialtyId,options)
else
-- In case the specialty is not one of the specialties of the internal table
return formatIdEntityWikidata(specialtyId, options)
end
-- Half
return formatIdEntityWikidata(specialtyId, options)
end
-- Variables
if not value then
return
end
-- Get data
local educationPlaceLink, educationPlaceLabel, educationPlaceEntityId = getData(value)
local educationPlace = toLink(educationPlaceLink, educationPlaceLabel, educationPlaceEntityId,options)
if not educationPlace then
return
end
-- Degrees
local degree
local degreesStatement = tableElement(qualifyings,'P512')
if degreesStatement then
local degrees = {}
local degreeId
for k, v in pairs(degreesStatement) do
degreeId = tableElement(v,'datavalue','value','id')
if degreeId then
table.insert(degrees, getDegree(degreeId, options))
end
end
degree = mw.text.listToText( degrees, '፣ ', ' ከምኡ’ውን ' )
end
-- Specialization
local specialization
local specializationsStatement = tableElement(qualifyings,'P812')
if specializationsStatement then
local specializations = {}
local specializationId
for k, v in pairs(specializationsStatement) do
specializationId = tableElement(v,'datavalue','value','id')
if specializationId then
table.insert(specializations, getSpecialization(specializationId, options))
end
end
specialization = mw.text.listToText( specializations, '፣ ', ' ከምኡ’ውን ' )
end
-- Add the specialization to the degree
local specializationDegree
if degree and specialization then
specializationDegree = degree .. ' ኣብ ' .. specialization
else
specializationDegree = degree or specialization
end
local period = formatPeriodWikidata(qualifyings, options)
-- Cases
--
if specializationDegree and period then
return educationPlace .. ' <small>(' .. specializationDegree .. '፤ ' .. period .. ')</small>'
elseif specializationDegree then
return educationPlace .. ' <small>(' .. specializationDegree .. ')</small>'
elseif period then
return educationPlace .. ' <small>(' .. period .. ')</small>'
else
return educationPlace
end
--if true then return require('Module:Tables').tostring(qualifyings) end -- Tests
end
-- Aliases for ease of use from the template property
--
p['ዝተማህረ ኣብ'] = p.formatEducatedIn
return p