Content deleted Content added
add some names, standardize abbreviations after IPNI convention |
adapt getBotanicalAuthorityFromWikiData from Module:Taxon authority to link author name if it has d:Property:P428 (botanist author abbreviation) on Wikidata |
||
Line 86:
function p.standardize_abbrev(abbrev)
return (abbrev:gsub("%.%s+", "."))
end
-- Adapted from getBotanicalAuthorityFromWikiData in [[Module:Taxon authority]].
function p.get_botanist_author_abbreviation(name)
local wikidata_id = mw.wikibase.getEntityIdForTitle(name)
if not (wikidata_id and mw.wikibase.isValidEntityId(wikidata_id)) then
local title_obj = mw.title.new(name).redirectTarget
if title_obj and title_obj.text then
wikidata_id = mw.wikibase.getEntityIdForTitle(name)
end
end
if wikidata_id and mw.wikibase.isValidEntityId(wikidata_id) then -- valid Wikidata id
local item = mw.wikibase.getEntity(wikidata_id)
local statements = item:getBestStatements('P428')[1] -- botanist author abbreviation
if statements ~= nil then
return statements.mainsnak.datavalue.value
end
end
return nil
end
Line 95 ⟶ 116:
if full_name then
return "[[" .. full_name .. "|" .. author .. "]]"
elseif p.get_botanist_author_abbreviation(author) then
return "[[" .. author .. "]]"
end
end)
|