Module:Index data: திருத்தங்களுக்கு இடையிலான வேறுபாடு

உள்ளடக்கம் நீக்கப்பட்டது உள்ளடக்கம் சேர்க்கப்பட்டது
No edit summary
No edit summary
வரிசை 1:
--[[RécupèreRetrieves lesthe donnéesdata defrom lathe page d'index etpage and enrichieenriches lesit avecwith Wikidata]]--
 
local wikidataTypeToIndexType = {
['Q3331189Q571'] = 'book',
['Q1238720Q41298'] = 'journal',
['Q28869365'] = 'journal',
['Q191067'] = 'journal',
['Q23622'] = 'dictionary',
['Q187685Q1266946'] = 'phdthesisthesis'
}
 
local indexToWikidata = {
-- type etand titretitle sontare gérésspecially spécialementmanaged
['sous_titresubtitle'] = 'P1680P392',
['volume'] = 'P478',
['edition'] = 'P393',
['author'] = 'P50',
['traducteurtranslator'] = 'P655',
['editeur_scientifiqueeditor'] = 'P98',
['illustrateurillustrator'] = 'P110',
['editeur'] = 'P123',
-- TODO ['School'] = 'PXXX',
['lieu'] = 'P291',
['year'] = 'P577',
['epigraphe'] = 'P7150',
['publisher'] = 'P123',
['place_of_publicationprinter'] = 'P91P872',
['viafaddress'] = 'P752P291',
-- ['partspublishedin'] = 'P253130P253129',
-- TODO ['publicationyear'] = 'PXXP577',
-- TODO ['bibliothequeviaf'] = 'PXXP752',
-- TODO ['clefparts'] = 'PXXP747',
 
-- TODO ['BNF_ARK'] = 'P4258', formatting problems
 
-- TODO ['source'] = 'PXX',
-- TODO ['image'] = 'PXX',
}
 
 
function indexDataWithWikidata(frame)
--create a clean table of parameters with blank parameters removed
local args = {}
 
for k,v in pairs(frame.args) do
if v ~= '' then
வரி 46 ⟶ 36:
end
mw.logObject(args)
 
local item = nil
if args.wikidata_item then
item = mw.wikibase.getEntity(args.wikidata_item)
if item == nil then
mw.addWarning('The Wikidata entity identifier [[d:' .. args.wikidata_item .. '|' .. args.wikidata_item .. ']] put in the "Wikidata entity" parameter of the Book page: does not seem valid. ')
end
end
வரி 62 ⟶ 50:
end
 
-- type depuisfrom Wikidata
if not args.type then
for _, statement in pairs(item:getBestStatements('P31')) do
if statement.mainsnak.datavalue ~= nil then
local typeId = statement.mainsnak.datavalue.value.id
if wikidataTypeToIndexType[typeId] then
args.type = wikidataTypeToIndexType[typeId]
வரி 74 ⟶ 62:
end
-- Titleimage sectionfrom Wikidata
if not args.titreimage then
for _, statement in pairs(item:getBestStatements('P18')) do
local value = item:formatStatements('P1476')['value'] or ''
if statement.mainsnak.datavalue.value =~= ''nil then
args.image = statement.mainsnak.datavalue.value
value = item:getLabel() or ''
end
if value ~= '' then
local siteLink = item:getSitelink()
if siteLink then
value = '[[' .. siteLink .. '|' .. value .. ']]'
end
args.titre = value .. ' [[File:OOjs UI icon edit-ltr.svg|View and edit data on Wikidata|10px|baseline|class=noviewer|link=d:' .. item.id .. '#P1476]]'
end
end
-- title from Wikidata
if not args.title then
-- Author
--local value = item:formatStatements('P1476')['value']
mw.logObject( args.author )
local value = item:formatStatements('P711')['value'] or ''
if not args.author then
local value = item:formatStatements('P50')['value'] or ''
mw.logObject( value )
if value == '' then
value = item:getLabel() or ''
வரி 103 ⟶ 83:
value = '[[' .. siteLink .. '|' .. value .. ']]'
end
args.authortitle = value .. ' [[File:OOjs UI icon edit-ltr.svg|View and edit data on Wikidata|10px|baseline|class=noviewer|link=d:' .. item.id .. '#P253075P1476]]'
end
end
 
-- Publisheryear property
if not args.publisheryear then
for _, statement in pairs(item:getBestStatements('P766')) do
local value = item:formatStatements('P123')['value'] or ''
if valuestatement.mainsnak.datavalue =~= ''nil then
local current_year = statement.mainsnak.datavalue.value.time
value = item:getLabel() or ''
args['year'] = mw.ustring.sub(current_year, 2, 5)
end
if value ~= '' then
local siteLink = item:getSitelink()
if siteLink then
value = '[[' .. siteLink .. '|' .. value .. ']]'
end
args.publisher = value .. ' [[File:OOjs UI icon edit-ltr.svg|View and edit data on Wikidata|10px|baseline|class=noviewer|link=d:' .. item.id .. '#P760 ]]'
end
end
 
-- year
if not args.year then
local value = item:formatStatements('P577')['value'] or ''
if value == '' then
value = item:getLabel() or ''
end
if value ~= '' then
local siteLink = item:getSitelink()
if siteLink then
value = '[[' .. siteLink .. '|' .. value .. ']]'
end
args.year = value .. ' [[File:OOjs UI icon edit-ltr.svg|View and edit data on Wikidata|10px|baseline|class=noviewer|link=d:' .. item.id .. '#P766 ]]'
end
end
 
-- place of publication
if not args.place_of_publication then
local value = item:formatStatements('P291')['value'] or ''
if value == '' then
value = item:getLabel() or ''
end
if value ~= '' then
local siteLink = item:getSitelink()
if siteLink then
value = '[[' .. siteLink .. '|' .. value .. ']]'
end
args.place_of_publication = value .. ' [[File:OOjs UI icon edit-ltr.svg|View and edit data on Wikidata|10px|baseline|class=noviewer|link=d:' .. item.id .. '#P253129 ]]'
end
end
-- viaf
if not args.viaf then
local value = item:formatStatements('P752')['value'] or ''
if value == '' then
value = item:getLabelWithLang('te') or ''
end
if value ~= '' then
local siteLink = item:getSitelink()
if siteLink then
value = '[[' .. siteLink .. '|' .. value .. ']]'
end
args.viaf = value .. ' [[File:OOjs UI icon edit-ltr.svg|View and edit data on Wikidata|10px|baseline|class=noviewer|link=d:' .. item.id .. '#P752 ]]'
end
end
-- parts
if not args.parts then
local value = item:formatStatements('P253130')['value'] or ''
if value == '' then
value = item:getLabelWithLang('te') or ''
end
if value ~= '' then
local siteLink = item:getSitelink()
if siteLink then
value = '[[' .. siteLink .. '|' .. value .. ']]'
end
args.parts = value .. ' [[File:OOjs UI icon edit-ltr.svg|View and edit data on Wikidata|10px|baseline|class=noviewer|link=d:' .. item.id .. '#P253130 ]]'
end
end
 
 
 
-- autresauthor propriétésproperties
for arg, propertyId in pairs(indexToWikidata) do
if not args[arg] then
local value = item:formatStatements(propertyId)["value"] or ''
if value ~= '' then
args[arg] = value
args[arg] = value .. ' [[File:OOjs UI icon edit-ltr.svg|View and edit data on Wikidata|10px|baseline|class=noviewer|link=d:' .. item.id .. '#' .. propertyId .. ']]'
end
end
"https://ta.wikisource.org/wiki/Module:Index_data" இலிருந்து மீள்விக்கப்பட்டது