Módulo:Control de autoridades

De Wiki TVenserio

La documentación para este módulo puede ser creada en Módulo:Control de autoridades/doc

require('Módulo:No globals')

local function cleanLink ( link, style )
	-- similar to mw.uri.encode
	local wikiLink = link
	if style == 'PATH' then
		wikiLink = mw.ustring.gsub( wikiLink, ' ', '%%%%20' )
	elseif style == 'WIKI' then
		wikiLink = mw.ustring.gsub( wikiLink, ' ', '_' )
	else -- if style == 'QUERY' then -- default
		wikiLink = mw.ustring.gsub( wikiLink, ' ', '+' )
	end
	wikiLink = mw.ustring.gsub( wikiLink, '%[', '%%5B' )
	wikiLink = mw.ustring.gsub( wikiLink, '%]', '%%5D' )
	wikiLink = mw.ustring.gsub( wikiLink, '%"', '%%%%22' )
	return wikiLink
end

local function generic ( id, link, parameter )
	local idlink = cleanLink( id, 'PATH' )
	link = mw.ustring.gsub( link, '$1', idlink )
	return '[' .. link .. ' ' .. id .. ']'
end

local function bncLink ( id, link, parameter )
	-- filtro local del BNC, para evadir multitud de identificadores de Wikidata que no se enlazan adecuadamente
	-- véase https://www.wikidata.org/wiki/Wikidata:Database_reports/Constraint_violations/P1890#%22Format%22_violations
	if ( string.match( id, '^%d%d%d%d%d%d%d%d%d$' ) ) then
		return generic ( id, link, parameter )
	end
	return false
end

local function bnfLink ( id, link, parameter )
	-- representación local del BNF, con doble enlace
	return generic( id, link, parameter ) .. ' [http://data.bnf.fr/ark:/12148/cb' .. id .. ' (data)]'
end

local function ineLink ( id, link, parameter )
	-- representación especial del INE, enlace no estándar con cinco parámetros utilizados
	local ineMainRE, ineTailRE = '^(%d%d)(%d%d%d)', '(%d%d)(%d%d)(%d%d)'
	local codProv, codMuni, codEC, codES, codNUC = string.match( id, ineMainRE .. ineTailRE .. '$' )
	if not codEC or not codES or not codNUC then
		codProv, codMuni = string.match( id, ineMainRE .. '$' )
		if codProv and codMuni then
			codEC, codES, codNUC = '00', '00', '00'
		else
			codProv, codMuni = string.match( id, ineMainRE )
			codEC, codES, codNUC = '', '', ''
		end
	end
	if codProv and codMuni then
		link = 'http://www.ine.es/nomen2/inicio_a.do?accion=busquedaAvanzada&inicio=inicio_a&subaccion=&botonBusquedaAvanzada=Consultar+selecci%C3%B3n&numPag=0&ordenAnios=ASC&comunidad=00&entidad_amb=no&poblacion_amb=T&poblacion_op=%3D&poblacion_txt=&denominacion_op=like&denominacion_txt=&codProv=$1&codMuni=$2&codEC=$3&codES=$4&codNUC=$5'
		link = link:gsub('$1', codProv):gsub('$2', codMuni):gsub('$3', codEC):gsub('$4', codES):gsub('$5', codNUC)
		return generic( id, link, parameter )
	end
	return id
end

local function commonscat ( id, link, parameter )
	-- representación especial del enlace a las categorías de Commons, para mantener el formato de enlace interwiki
	local idlink = cleanLink( id, 'WIKI' )
	link = mw.ustring.gsub( link, '$1', idlink )
	return '<span class="plainlinks">[' .. link .. ' ' .. id .. ']</span>'
end

local function sisterprojects ( id, link, parameter )
	-- enlaces interproyecto
	local prefix = {
		-- Ejemplo: -- enwiki = 'w:en',
		commonswiki = 'c',
		eswikivoyage = 'voy',
		eswiktionary = 'wikt',
		eswikibooks = 'b',
		eswikinews = 'n',
		eswikiversity = 'v',
		eswikiquote = 'q',
		eswikisource = 's',
		mediawikiwiki = 'mw',
		metawiki = 'm',
		specieswiki = 'species',
	}
	if prefix[ parameter ] then
		return '[['..prefix[ parameter ]..':'..id..'|'..id..']]'
	end
	return false
end

function getCommonsValue ( itemId )
	local commonslink = ''
	local categories = ''

	local property = getIdsFromWikidata( itemId, 'P373' )
	if property and property[1] then
		property = property[1]
		commonslink = commonslink .. getLink( 373, property, commonscat )
	else
		property = ''
	end

	local sitelink = getIdsFromSitelinks( itemId, 'commonswiki' )
	if sitelink and sitelink[1] then
		sitelink = sitelink[1]
		if sitelink ~= 'Category:' .. property then
			if commonslink == '' then
				commonslink = commonslink .. sisterprojects( sitelink, nil, 'commonswiki' )
			end
		end
	else
		sitelink = ''
	end

	if property and sitelink then
		if sitelink ~= 'Category:' .. property then
			-- categories = categories .. '[[Categoría:Wikipedia:Control de autoridades con enlaces diferentes de Commons]]'
		end
	elseif sitelink then -- not property
		-- categories = categories .. '[[Categoría:Wikipedia:Control de autoridades sin Commonscat]]'
	elseif property then -- not sitelink
		-- categories = categories .. '[[Categoría:Wikipedia:Control de autoridades sin Commons]]'
	else -- not property and not sitelink
		-- categories = categories .. '[[Categoría:Wikipedia:Control de autoridades sin ningún enlace de Commons]]'
	end
	if commonslink ~= '' then
		-- Special:MediaSearch
		local mediasearch = 'https://commons.wikimedia.org/wiki/Special:MediaSearch?type=image&search=%22$1%22'
		commonslink = commonslink .. ' / ' .. commonscat( itemId, mediasearch )

		return { commonslink .. categories }
	end
	return {}
end

local conf = {}
--In this order: name of the parameter, label, propertyId in Wikidata, formatting function, category id
-- -- name of the parameter: unique name
-- -- label: internal link in wiki format
-- -- propertyId in Wikidata: number without 'P' suffix
-- -- formatting function: one of these four options
-- -- -- local function (like 'generic')
-- -- -- string 'y' (yes), to show a default identifier 'ID'
-- -- -- string 'n' (no), to show the real identifier
-- -- -- any other string, to show this string as identifier ('id', 'url', 'link', ...)
-- -- category id: one of these tree options
-- -- -- number 0, to not add category
-- -- -- number 1, to add a category based on the name of the parameter
-- -- -- any string, to add a category based on this string
conf.databases = {}
conf.databases[1] =	{}
conf.databases[1].name = '[[Control de autoridades]]'
conf.databases[1].list = {
	{
		title = 'Proyectos Wikimedia',
		group = {
			{ 'Wikidata', '[[Archivo:Wikidata-logo.svg|20px|link=Wikidata|alt=Wd|Wikidata]] Datos', 'Wikidata:$1', 'n', 0 },
			{ 'Commons', '[[Archivo:Commons-logo.svg|15px|link=Wikimedia Commons|alt=Commonscat|Commonscat]] Multimedia', getCommonsValue, 'n', 0 },
			{ 'Wikivoyage', '[[Archivo:Wikivoyage-logo.svg|15px|link=Wikiviajes|alt=Wikivoyage|Wikivoyage]] Guía turística', 'eswikivoyage', sisterprojects, 0 },
			{ 'Wiktionary', '[[Archivo:Wiktionary-logo.svg|15px|link=Wikcionario|alt=Wiktionary|Wiktionary]] Diccionario', 'eswiktionary', sisterprojects, 0 },
			{ 'Wikibooks', '[[Archivo:Wikibooks-logo.svg|15px|link=Wikilibros|alt=Wikibooks|Wikibooks]] Libros y manuales', 'eswikibooks', sisterprojects, 0 },
			{ 'Wikinews', '[[Archivo:Wikinews-logo.svg|20px|link=Wikinoticias|alt=Wikinews|Wikinews]] Noticias', 'eswikinews', sisterprojects, 0 },
			{ 'Wikiversity', '[[Archivo:Wikiversity-logo.svg|15px|link=Wikiversidad|alt=Wikiversity|Wikiversity]] Recursos didácticos', 'eswikiversity', sisterprojects, 0 },
			{ 'Wikiquote', '[[Archivo:Wikiquote-logo.svg|15px|link=Wikiquote|alt=Wikiquote|Wikiquote]] Citas célebres', 'eswikiquote', sisterprojects, 0 },
			{ 'Wikisource', '[[Archivo:Wikisource-logo.svg|15px|link=Wikisource|alt=Wikisource|Wikisource]] Textos', 'eswikisource', sisterprojects, 0 },
			{ 'MediaWiki', '[[Archivo:MediaWiki-2020-icon.svg|20px|link=MediaWiki|alt=MediaWiki|MediaWiki]] MediaWiki', 'mediawikiwiki', sisterprojects, 0 },
			{ 'Meta-Wiki', '[[Archivo:Wikimedia Community Logo.svg|15px|link=Wikimedia Meta-Wiki|alt=Meta-Wiki|Meta-Wiki]] Coordinación', 'metawiki', sisterprojects, 0 },
			{ 'Wikispecies', '[[Archivo:Wikispecies-logo.svg|15px|link=Wikispecies|alt=Wikispecies|Wikispecies]] Especies', 'specieswiki', sisterprojects, 0 },
		},
	},
	{
		title = 'Identificadores',
		group = {
			{ 'ISSN', '[[ISSN]]', 236, 'n', 1 },
			{ 'VIAF', '[[Fichero de Autoridades Virtual Internacional|VIAF]]', 214, 'n', 1 },
			{ 'ISNI', '[[International Standard Name Identifier|ISNI]]', 213, 'n', 1 },

			{ 'BCN', '[[Biblioteca del Congreso de la Nación Argentina|BCN]]', 2879, 'n', 1 },
			{ 'BNA', '[[Biblioteca Nacional de la República Argentina|BNA]]', 3788, 'n', 1 },
			{ 'BNE', '[[Biblioteca Nacional de España|BNE]]', 950, 'n', 1 },
			{ 'BNF', '[[Biblioteca Nacional de Francia|BNF]]', 268, bnfLink, 1 },
			{ 'BNM', '[[Biblioteca Nacional de México|BNM]]', 4440, 'n', 1 },
			{ 'BNC', '[[Biblioteca Nacional de Chile|BNC]]', 1890, bncLink, 1 },
			{ 'CANTIC', '[[Biblioteca de Cataluña|CANTIC]]', 9984, 'n', 1 },
			{ 'GND', '[[Gemeinsame Normdatei|GND]]', 227, 'n', 1 },
			{ 'LCCN', '[[Library of Congress Control Number|LCCN]]', 244, 'n', 1 },
			{ 'NCL', '[[Biblioteca central de Taiwán|NCL]]', 1048, 'n', 0 },
			{ 'NDL', '[[Biblioteca Nacional de la Dieta|NDL]]', 349, 'n', 0 },
			{ 'NKC', '[[Biblioteca Nacional de la República Checa|NKC]]', 691, 'n', 0 },
			{ 'NLA', '[[Biblioteca Nacional de Australia|NLA]]', 409, 'n', 1 },
			{ 'RLS', '[[Biblioteca del Estado Ruso|BER]]', 947, 'n', 0 },

			{ 'CINII', '[[CiNii]]', 271, 'n', 0 },
			{ 'NARA', '[[National Archives and Records Administration|NARA]]', 1225, 'n', 0 },
			{ 'LCCNLCOC', '[[Library of Congress Control Number|LCCN]]', 1144, 'n', 0 },
			{ 'SNAC', '[[d:Q29861311|SNAC]]', 3430, 'n', 1 },
			{ 'S2', '[[:d:Q22908627|S2]]', 4012, 'n', 0 },
			{ 'SUDOC', '[[Système universitaire de documentation|SUDOC]]', 269, 'n', 0 },
			{ 'ULAN', '[[Union List of Artist Names|ULAN]]', 245, 'n', 1 },
			{ 'frickSpain ', '[[Colección Frick|research.frick]]', 8572, 'n', 1 },			
			{ 'ORCID', '[[ORCID]]', 496, 'n', 1 },
			{ 'Scopus', '[[Scopus]]', 1153, 'n', 1 },
			-- { 'SELIBR', '[[LIBRIS|SELIBR]]', 906, 'n', 1 },
			{ 'BIBSYS', '[[BIBSYS]]', 1015, 'n', 1 },
			{ 'IPNIaut', '[[Índice Internacional de Nombres de las Plantas|IPNI]]', 586, 'n', 'IPNI' },
			{ 'MGP', '[[Mathematics Genealogy Project|MGP]]', 549, 'n', 0 },
			{ 'autores.uy', '[[autores.uy]]', 2558, 'n', 1 },
			{ 'Slovenska biografija', '[[:d:Q15975890|Slovenska biografija]]', 1254, 'n', 0 },
			{ 'SBN', '[[Istituto Centrale per il Catalogo Unico|ICCU]]', 396, 'n', 1 },
			{ 'ARAE', '[[:d:Q105580684|ARAE]]', 9226, 'n', 1 },
			{ 'DeutscheBiographie', '[[Deutsche Biographie]]', 7902, 'n', 1 },	
			
			{ 'CCBAE', '[[:d:Q61505171|CCBAE]]', 6493, 'n', 1 },
			-- { 'DIR3', '[[Directorio Común de Unidades Orgánicas y Oficinas|DIR3]]', 6222, 'n', 1 },
			{ 'CensoGuia', '[[Censo-Guía de Archivos de España e Iberoamérica]]', 3998, 'n', 'Censo-Guía' },
			{ 'Libraries.org', 'Libraries.org', 4848, 'n', 1 },
			{ 'DirectorioMuseos', '[[:d:Q56246649|Directorio de Museos y Colecciones de España]]', 5763, 'n', 1 },
			{ 'SUCA', 'SUCA', 5946, 'n', 1 },

			{ 'BOE', '[[Boletín Oficial del Estado|BOE]]', 4256, 'n', 1 },

			{ 'RoyalSociety', '[[Royal Society]]', 2070, 'url', 'Royal Society' },
			{ 'HAW', '[[Academia de Ciencias y Humanidades de Heidelberg|HAW]]', 2273, 'n', 1 },
			{ 'SAW', '[[Academia Sajona de Ciencias de Leipzig|SAW]]', 3411, 'n', 1 },
			{ 'KNAW', '[[Real Academia de Artes y Ciencias de los Países Bajos|KNAW]]', 2454, 'n', 1 },
			-- { 'KVAB', '[[Real Academia Flamenca de Ciencias y Artes de Bélgica|KVAB]]', 3887, 'n', 1 },
			{ 'Leopoldina', '[[Deutsche Akademie der Naturforscher Leopoldina|Leopoldina]]', 3413, 'n', 1 },
			{ 'CONICET', '[[CONICET]]', 3900, 'n', 1 },
			{ 'Grierson', '[[Directorio de científicos argentinos Dra. Grierson|Grierson]]', 3946, 'n', 1 },
			{ 'RANM', '[[Real Academia Nacional de Medicina|RANM]]', 3945, 'n', 1 },
			-- { 'ANMF', '[[Académie Nationale de Médecine|ANMF]]', 3956, 'n', 1 },
			{ 'Léonore', '[[Base Léonore|Léonore]]', 640, 'n', 0 },
			{ 'USCongress', '[[Biographical Directory of the United States Congress|US Congress]]', 1157, 'n', 0 },
			{ 'BPN', '[[Biografisch Portaal|BPN]]', 651, 'n', 1 },

			-- { 'ISCO', '[[d:Q1233766|ISCO]]', 952, 'n', 1 },
			{ 'AAT', '[[Art & Architecture Thesaurus|AAT]]', 1014, 'n', 1 },
			{ 'OpenLibrary', '[[Open Library]]', 648, 'n', 'Open Library' },
			{ 'PARES', '[[PARES]]', 4813, 'n', 1 },
			{ 'SSRN', '[[Social Science Research Network|SSRN]]', 3747, 'n', 'SSRN autor' },
			{ 'SIKART', '[[SIKART]]', 781, 'n', 0 },
			{ 'KULTURNAV', '[[KulturNav]]', 1248, 'id', 0 },
			{ 'RKDartists', '[[Rijksbureau voor Kunsthistorische Documentatie|RKD]]', 650, 'n', 1 },
			{ 'GoogleScholar', '[[Google Académico]]', 1960, 'n', 'Google Académico' },
			-- { 'Microsoft Academic', '[[Microsoft Academic]]', 6366, 'n', 1 },
			{ 'RID', '[[ResearcherID]]', 1053, 'n', 1 },
			{ 'NLM', '[[Biblioteca Nacional de Medicina de los Estados Unidos|NLM]]', 1055, 'n', 1 },
			{ 'Latindex', '[[Latindex]]', 3127, 'n', 1 },
			{ 'ERIH PLUS', '[[ERIH PLUS]]', 3434, 'n', 1 },
			{ 'IPNIpub', '[[Índice Internacional de Nombres de las Plantas|IPNI]]', 2008, 'n', 1 },
			{ 'SUDOCcat', '[[Système universitaire de documentation|SUDOC]]', 1025, 'n', 'SUDOC catálogo' },
			{ 'ZDB', '[[Zeitschriftendatenbank|ZDB]]', 1042, 'n', 1 },
			{ 'NorwegianRegister', '[[Norsk senter for forskningsdata|Norwegian Register]]', 1270, 'n', 'Norwegian Register' },
			{ 'DOAJ', '[[Directory of Open Access Journals|DOAJ]]', 5115, 'n', 1 },
			{ 'ACNP', 'ACNP', 6981, 'n', 1 },
			{ 'DipFedBra', '[[Cámara de Diputados de Brasil]]', 7480, 'n', 1 },			
			{ 'HCDN', '[[Cámara de Diputados de la Nación Argentina|Estadísticas HCDN]]', 4693, 'n', 1 },
			{ 'HCDNbio', '[[Cámara de Diputados de la Nación Argentina|Biografía HCDN]]', 5225, 'n', 1 },
			{ 'Directorio Legislativo', 'Directorio Legislativo', 6585, 'n', 0 },
			-- { 'Legislatura CABA', '[[Legislatura de la Ciudad de Buenos Aires|Legislatura CABA]]', 4667, 'n', 1 },
			{ 'Archivo Histórico de Diputados de España', '[[Congreso de los Diputados|Archivo Histórico de Diputados (1810-1977)]]', 9033, 'n', 1 },
			{ 'Senadores de España (1834-1923)', '[[Senado de España|Senadores de España (1834-1923)]]', 10265, 'n', 1 },
			{ 'Asamblea de Madrid', '[[Asamblea de Madrid]]', 4797, 'n', 1 },
			{ 'BCNCL', '[[Biblioteca del Congreso Nacional de Chile|Biografías BCN]]', 5442, 'url', 0 },
			{ 'RBD', '[[Ministerio de Educación de Chile|RBD MINEDUC]]', 1919, 'n', 0 },
			{ 'CineChile', 'CineChile', 6750, 'url', 0 },
			{ 'Tebeosfera-autor', '[[Tebeosfera]]', 5562, 'n', 1 },
			{ 'DPRR', 'DPRR', 6863, 'n', 0},
			{ 'tribunsdelaplebe.fr', 'TDLP', 8961, 'n', 0},
			{ 'Pleiades', 'Pleiades', 1584, 'n', 0},
			{ 'IMO', '[[Organización Marítima Internacional|IMO]]', 458, 'n', 0},
			{ 'Mnemosine', '[[Mnemosine. Biblioteca Digital de La otra Edad de Plata|Mnemosine]]', 10373, 'n', 0 },
			{ 'Renacyt', '[[Registro Nacional Científico, Tecnológico y de Innovación Tecnológica|Renacyt]]', 10452, 'n', 0 },
            { 'MuseodeOrsayArtistas', '[[Museo de Orsay]]', 2268, 'n', 'Museo de Orsay (artista)' },
            { 'Thyssen-BornemiszaArtistas', '[[Museo Thyssen-Bornemisza|Thyssen-Bornemisza]]', 2431, 'n', 'Thyssen-Bornemisza (artista)' },
            { 'AWARE', '[[Archives of Women Artists, Research and Exhibitions|AWARE]]', 6637, 'url', 0 },
		},
	},
	{
		title = 'Diccionarios y enciclopedias',
		group = {
			{ 'Auñamendi', '[[Enciclopedia Auñamendi|Auñamendi]]', 3218, 'n', 1 },
			-- { 'GEA', '[[Gran Enciclopedia Aragonesa|GEA]]', 1807, 'n', 1 },
			{ 'GEN', '[[Gran Enciclopedia Navarra|GEN]]', 7388, 'n', 1 },
			{ 'DBSE', '[[Diccionario biográfico del socialismo español|DBSE]]', 2985, 'url', 1 },
			{ 'DBE', '[[Diccionario biográfico español|DBE]]', 4459, 'url', 1 },
			{ 'HDS', '[[Historical Dictionary of Switzerland|HDS]]', 902, 'n', 0 },
			{ 'LIR', '[[Diccionario histórico de Suiza|LIR]]', 886, 'n', 0 },
			{ 'TLS', '[[Theaterlexikon der Schweiz|TLS]]', 1362, 'n', 0 },
			{ 'Britannica', '[[Enciclopedia Británica|Britannica]]', 1417, 'url', 0 },
			{ 'ELEM', '[[Enciclopedia de la Literatura en México|ELEM]]', 1565, 'n', 0 },
			{ 'Treccani', '[[Enciclopedia Treccani|Treccani]]', 4223, 'url', 0 },
			{ 'Iranica', '[[Encyclopædia Iranica]]', 3021, 'n', 1 },	
		},
	},
	{
		title = 'Repositorios digitales',
		group = {
			{ 'PerséeRevista', '[[Persée (portal)|Persée]]', 2733, 'n', 'Persée revista' },
			{ 'DialnetRevista', '[[Dialnet]]', 1609, 'n', 'Dialnet revista' },
			{ 'Redalyc', '[[Redalyc]]', 3131, 'n', 1 },
			-- { 'UNZrevista', '[[UNZ.org|UNZ]]', 2735, 'n', 0 },
			-- { 'JSTORrevista', '[[JSTOR]]', 1230, 'n', 'JSTOR revista' },
			{ 'HathiTrust', '[[HathiTrust]]', 1844, 'n', 1 },
			{ 'Galicianaobra', '[[Galiciana]]', 3004, 'n', 'Galiciana obra' },
			{ 'Trove', '[[Trove]]', 5603, 'n', 1 },
			{ 'BVMCobra', '[[Biblioteca Virtual Miguel de Cervantes|BVMC]]', 3976, 'n', 'BVMC obra' },
			{ 'BVMCpersona', '[[Biblioteca Virtual Miguel de Cervantes|BVMC]]', 2799, 'n', 'BVMC persona' },
			{ 'Persée', '[[Persée (portal)|Persée]]', 2732, 'n', 1 },
			{ 'Dialnet', '[[Dialnet]]', 1607, 'n', 1 },
			{ 'GutenbergAutor', '[[Proyecto Gutenberg]]', 1938, 'n', 'Proyecto Gutenberg autor' },
			{ 'BHL-bibliografia', '[[Biodiversity Heritage Library|BHL]]', 4327, 'n', 0 },			
			-- { 'UNZautor', '[[UNZ.org|UNZ]]', 2734, 'n', 'UNZ' },
			{ 'TLL', '[[:d:Q570837|TLL]]', 7042, 'n', 'The Latin Library' },
			{ 'BDCYL', '[[Biblioteca Digital de Castilla y León|BDCYL]]', 3964, 'n', 1 },
			{ 'BVPB', '[[Biblioteca Virtual del Patrimonio Bibliográfico|BVPB]]', 4802, 'n', 1 },
			{ 'PDCLM', '[[d:Q61500710|Patrimonio Digital de Castilla-La Mancha]]', 6490, 'n', 1 },	
			{ 'BVANDALUCIA', '[[Biblioteca Virtual de Andalucía|BVA]]', 6496, 'n', 1 },				
			{ 'BVPHautoridad', '[[Biblioteca Virtual de Prensa Histórica|BVPH]]', 6492, 'n', 1 },					
			{ 'BivaldiAutor', '[[Biblioteca Valenciana Digital|BiValDi]]', 3932, 'n', 'Bivaldi autor' },
			{ 'GalicianaAutor', '[[Galiciana]]', 3307, 'n', 'Galiciana autor' },
			{ 'Packard Humanities Institute', '[[Packard Humanities Institute|PHI]]', 6941, 'n', 0 },
			{ 'Europeana', '[[Europeana]]', 7704, 'n', 1 },
			{ 'DOI', '[[Identificador de objeto digital|DOI]]', 356, 'n', 1 },
			{ 'Handle', '[[Sistema Handle|Handle]]', 1184, 'url', 1 },
			{ 'MNCARS', '[[Museo Nacional Centro de Arte Reina Sofía|MNCARS]]', 4439, 'url', 1 },
			{ 'MuseoDelPradoPersona', '[[Museo del Prado]]', 5321, 'n', 'Museo del Prado (persona)' },
			{ 'MuseoDelPradoObra', '[[Museo del Prado]]', 8905, 'n', 'Museo del Prado (obra)' },
            { 'Museo Smithsoniano de Arte AmericanoPersona', '[[Museo Smithsoniano de Arte Americano|SAAM]]', 1795, 'n', 'SAAM (persona)' },
			{ 'Museo Smithsoniano de Arte AmericanObra', '[[Museo Smithsoniano de Arte Americano|SAAM]]', 4704, 'n', 'SAAM (obra)' },
		},
	},
	{
		title = 'Hemerotecas digitales',
		group = {
			{ 'HemBNE', '[[Hemeroteca Digital de la Biblioteca Nacional de España|Hemeroteca digital de la BNE]]', 2768, 'n', 1 },
			{ 'BVPH', '[[Biblioteca Virtual de Prensa Histórica]]', 2961, 'n', 1 },
			{ 'Memoriademadrid', '[[Memoriademadrid]]', 7372, 'n', 1 },
		},
	},
{
		title = 'Astronomía',
		group = {
			{ 'Simbad', '[[SIMBAD]]', 3083, 'n', 0 },
			{ 'JPL-Small-Body-Database', '[[JPL Small-Body Database|JPL]]', 716, 'n', 0 },
			{ 'MPC', '[[Centro de Planetas Menores|MPC]]', 5736, 'n', 0 },
			{ 'NASA-Exoplanet-Archive', '[[NASA Exoplanet Archive]]', 5667, 'n', 0 },			
			{ 'GazPlaNom', 'Gazetteer of Planetary Nomenclature', 2824, 'n', 0 },
		},
	},
	{
		title = 'Lugares',
		group = {
			{ 'OSM', '[[OpenStreetMap|OSM]]', 402, 'n', 'Relación OSM' },
			{ 'TGN', '[[Getty Thesaurus of Geographic Names|TGN]]', 1667, 'n', 1 },
			{ 'AtlasIR', '[[:d:Q24575107|Atlas Digital del Imperio Romano]]', 1936, 'n', 0 },
			{ 'Pleiades', '[[:d:Q24423804|Pleiades]]', 1584, 'n', 0 },
			{ 'TmGEO', '[[:d:Q22094624|Trismegistos GEO]]', 1958, 'n', 0 },
			{ 'SNCZI-IPE-EMBALSE', '[[Sistema Nacional de Cartografía de Zonas Inundables|SNCZI]]-IPE', 4568, 'n', 'SNCZI-IPE embalse' },
			{ 'SNCZI-IPE-PRESA', '[[Sistema Nacional de Cartografía de Zonas Inundables|SNCZI]]-IPE', 4558, 'n', 'SNCZI-IPE presa' },
			{ 'NATURA2000', '[[Red Natura 2000|Natura 2000]]', 3425, 'n', 'Natura 2000' },
			{ 'WWF', '[[Fondo Mundial para la Naturaleza|WWF]]', 1294, 'n', 1 },
			{ 'IDESCAT', '[[Instituto de Estadística de Cataluña|IDESCAT]]', 4335, 'n', 1 },
			{ 'INE', '[[Instituto Nacional de Estadística (España)|INE]]', 772, ineLink, 1 },
			{ 'INE Portugal', '[[Instituto Nacional de Estatística (Portugal)|INE]]', 6324, 'n', 1 },
			{ 'ISTAT', '[[Istituto Nazionale di Statistica|ISTAT]]', 635, 'n', 1 },			
			{ 'OFS-Suiza', '[[Oficina Federal de Estadística (Suiza)|OFS]]', 771, 'n', 1 },			
			{ 'IBGE', '[[Instituto Brasileiro de Geografia e Estatística|IBGE]]', 1585, 'n', 1 },
			{ 'TOID', '[[TOID]]', 3120, 'n', 1 },			
			{ 'INSEE-commune', '[[Institut National de la Statistique et des Études Économiques|INSEE]]', 374, 'n', 'INSEE (comuna)' },
		    { 'INSEE-departamento', '[[Institut National de la Statistique et des Études Économiques|INSEE]]', 2586, 'n', 'INSEE (departamento)' },
			{ 'INSEE-region', '[[Institut National de la Statistique et des Études Économiques|INSEE]]', 2585, 'n', 'INSEE (región)' },
			{ 'INSEE-canton', '[[Institut National de la Statistique et des Études Économiques|INSEE]]', 2506, 'n', 'INSEE (cantón)' },
			{ 'SIRUTA', '[[SIRUTA]]', 843, 'n', 1 },
			{ 'LAU', '[[Unidad administrativa local|LAU]]', 782, 'n', 1 },
			{ 'KSH', '[[Központi Statisztikai Hivatal|KSH]]', 939, 'n', 1 },
			{ 'OKATO', '[[OKATO]]', 721, 'n', 1 },
			{ 'OSTAT', '[[Statistik Austria|ÖSTAT]]', 964, 'n', 'ÖSTAT-Nr'},
			{ 'GNIS', '[[Geographic Names Information System|GNIS]]', 590, 'n', 0},
		},
	},
	{
		title = 'Arquitectura',
		group = {
			{ 'DocomomoIberico', '[[Fundación Docomomo Ibérico|Docomomo Ibérico]]', 3758, 'n', 'Docomomo Ibérico' },
			{ 'COAMinmueble', '[[Colegio Oficial de Arquitectos de Madrid|COAM]]', 2917, 'n', 'COAM inmueble' },
			{ 'COAMpersona', '[[Colegio Oficial de Arquitectos de Madrid|COAM]]', 4488, 'n', 'COAM persona' },
		},
	},
	{
		title = 'Faros',
		group = {
			{ 'ARHLS', '[[Amateur Radio Lighthouse Society|ARHLS]]', 2980, 'n', 0 },
			{ 'NGA', '[[Agencia Nacional de Inteligencia-Geoespacial|NGA]]', 3563, 'n', 0 },
			{ 'UKHO', '[[Instituto Hidrográfico del Reino Unido|UKHO]]', 3562, 'n', 0 },
			{ 'MarineTraffic', '[[MarineTraffic]]', 3601, 'n', 0 },
			{ 'OnlineListofLights', '[[:d:Q843152|Online List of Lights]]', 3223, 'n', 0 },			
		},
	},
	{
		title = 'Patrimonio histórico',
		group = {
			{ 'World Heritage Site', '[[Patrimonio de la Humanidad]]', 757, 'n', 'Centro del Patrimonio Mundial' },
			{ 'CNMLBH', '[[Comisión Nacional de Monumentos, de Lugares y de Bienes Históricos|CNMLBH]]', 4587, 'n', 'cnmlbh' },
			{ 'IGESPAR', '[[Instituto de Gestão do Património Arquitetónico e Arqueológico|IGESPAR]]', 1702, 'n', 1 },
			{ 'SIPA', '[[Sistema de Informação para o Património Arquitetónico|SIPA]]', 1700, 'n', 1 },
			{ 'Infopatrimonio', '[[:d:Q64745161|Infopatrimônio]]', 4372, 'n', 'Infopatrimônio' },
			{ 'AustriaObjektID', 'Austria ObjektID', 2951,  'n', 'Austria ObjektID' },
			{ 'FBBID', '[[Fredede og Bevaringsværdige Bygninger|FBB]]', 2783,  'n', 'FBB' },
			{ 'Fornminnesregistret', '[[Fornminnesregistret|FMIS]]', 1260,  'n', 'FMIS' },
			{ 'BerlinerKulturdenkmal', 'Berliner Kulturdenkmal', 2424, 'n', 'Berliner Kulturdenkmal' },
			{ 'NHLE', '[[National Heritage List for England|NHLE]]', 1216, 'n', 1 },
			{ 'NRHP', '[[Registro Nacional de Lugares Históricos|NRHP]]', 649, 'n', 1 },
			{ 'KULTURMINNE', '[[Riksantikvaren|Kulturminne]]', 758, 'n', 'Kulturminne' },
			{ 'CRHP', '[[:d:Q3456275|CRHP]]', 477, 'n', 1 },
			{ 'MERIMEE', '[[Base Mérimée|Mérimée]]', 380, 'n', 'Mérimée' },
			{ 'CADW', '[[Cadw]]', 1459, 'n', 'Cadw' },
			{ 'Památkový Katalog', '[[Památkový katalog]]', 762, 'n', 'Památkový katalog' },
			{ 'PatrimonioIran', 'Patrimonio Nacional de Irán', 1369, 'n', 'Patrimonio Nacional de Irán' },
			{ 'Rijksmonument', 'Rijksmonument', 359, 'n', 'Rijksmonument' },
			{ 'BIC', '[[Bien de Interés Cultural (España)|BIC]]', 808, 'n', 1 },
			{ 'BCIN', '[[Bien Cultural de Interés Nacional|BCIN]]', 1586, 'n', 1 },
			{ 'IPAC', '[[Inventario del Patrimonio Arquitectónico de Cataluña|IPAC]]', 1600, 'n', 1 },
			{ 'IGPCV', '[[Inventario General del Patrimonio Cultural Valenciano|IGPCV]]', 2473, 'n', 1 },
			{ 'IAPH', '[[Instituto Andaluz del Patrimonio Histórico|IAPH]]', 8425, 'n', 0 },			
			{ 'BDI-IAPH', '[[Instituto Andaluz del Patrimonio Histórico|Patrimonio Inmueble de Andalucía]]', 3318, 'n', 1 },
			{ 'SIPCA', '[[SIPCA]]', 3580, 'n', 1 },
			{ 'PWJCYL', '[[Junta de Castilla y León|Patrimonio Web JCyL]]', 3177, 'n', 'Patrimonio Web JCyL' },
			{ 'CPCCLM', '[[Catálogo de Patrimonio Cultural de Castilla-La Mancha]]', 6539, 'n', 1 },			
			{ 'HispaniaNostra', '[[Lista roja de patrimonio en peligro|Lista Roja Hispania Nostra]]', 4868, 'url', 'Lista Roja Hispania Nostra' },
			{ 'HGC', '[[Heritage Gazetteer for Cyprus]]', 6916, 'n', 1 },	
			{ 'HGL', '[[Heritage Gazetteer of Libya]]', 6751, 'n', 1 },
		},
	},
	{
		title = 'Deportistas',
		group = {
			{ 'COI', '[[Comité Olímpico Internacional|COI]]', 5815, 'n', 0 },
			{ 'World Athletics', '[[World Athletics]]', 1146, 'n', 0 },
			{ 'Liga Diamante', '[[Liga de Diamante]]', 3923, 'n', 0 },
			{ 'ITU', '[[Unión Internacional de Triatlón|ITU]]', 3604, 'n', 0 },
			{ 'ATP', '[[Asociación de Tenistas Profesionales|ATP]]', 536, 'n', 0 },
			{ 'Copa Davis', '[[Copa Davis]]', 2641, 'n', 0 },
			{ 'WTA', '[[Asociación de Tenis Femenino|WTA]]', 597, 'n', 0 },
			{ 'Fed Cup', '[[Copa Billie Jean King|Fed Cup]]', 2642, 'n', 0 },
			{ 'ITF', '[[Federación Internacional de Tenis|ITF]]', 599, 'n', 0 },
			{ 'ITHF', '[[Salón de la Fama del Tenis Internacional|ITHF]]', 3363, 'n', 0 },
			{ 'ITTF', '[[Federación Internacional de Tenis de Mesa|ITTF]]', 1364, 'n', 0 },
			{ 'FIFA', '[[FIFA]]', 1469, 'n', 0 },
			{ 'UEFA', '[[UEFA]]', 2276, 'n', 0 },
			{ 'Soccerway', '[[Soccerway]]', 2369, 'n', 0 },
			{ 'Transfermarkt', '[[Transfermarkt]]', 2446, 'n', 0 },
			{ 'FootballDatabase', '[[FootballDatabase]]', 3537, 'n', 0 },
			{ 'BDFutbol', '[[BDFutbol]]', 3655, 'n', 0 },
			{ 'EPCR', '[[European Professional Club Rugby|EPCR]]', 3666, 'n', 0 },
            { 'FIDE', '[[Federación Internacional de Ajedrez|FIDE]]', 1440, 'n', 0 },
			{ 'BoxRec', '[[BoxRec]]', 1967, 'n', 0 },
			{ 'Sherdog', '[[Sherdog]]', 2818, 'n', 0 },
			{ 'WWE', '[[WWE]]', 2857, 'n', 0 },
			{ 'NSK', '[[Asociación Japonesa de Sumo|NSK]]', 3385, 'n', 0 },
			{ 'IJF', '[[Federación Internacional de Yudo|IJF]]', 4559, 'n', 0 },
			{ 'FINA', '[[Federación Internacional de Natación|FINA]]', 3408, 'n', 0 },
			{ 'ISHOF', '[[International Swimming Hall of Fame|ISHOF]]', 3691, 'n', 0 },
			{ 'NFL', '[[National Football League|NFL]]', 3539, 'n', 0 },
			{ 'NHL', '[[National Hockey League|NHL]]', 3522, 'n', 0 },
			{ 'FIH', '[[Federación Internacional de Hockey|FIH]]', 3742, 'n', 0 },
			{ 'MLB', '[[Grandes Ligas de Béisbol|MLB]]', 3541, 'n', 0 },
			{ 'FIL', '[[Federación Internacional de Luge|FIL]]', 2990, 'n', 0 },
			{ 'IBSF', '[[Federación Internacional de Bobsleigh y Skeleton|IBSF]]', 2991, 'n', 0 },
			{ 'WAF', '[[Federación Internacional de Tiro con Arco|WAF]]', 3010, 'n', 0 },
			{ 'FEI', '[[Federación Ecuestre Internacional|FEI]]', 3111, 'n', 0 },
			{ 'FIE', '[[Federación Internacional de Esgrima|FIE]]', 2423, 'n', 0 },
			{ 'CEE', '[[Confederación Europea de Esgrima|CEE]]', 4475, 'n', 0 },
			{ 'IBU', '[[Unión Internacional de Biatlón|IBU]]', 2459, 'n', 0 },
			{ 'ISU', '[[Unión Internacional de Patinaje sobre Hielo|ISU]]', 2694, 'n', 0 },
			{ 'FIG', '[[Federación Internacional de Gimnasia|FIG]]', 2696, 'n', 0 },
			{ 'UIPM', '[[Unión Internacional de Pentatlón Moderno|UIPM]]', 2726, 'n', 0 },
			{ 'BWF', '[[Federación Mundial de Bádminton|BWF]]', 2729, 'n', 0 },
			{ 'WCF', '[[Federación Mundial de Curling|WCF]]', 3557, 'n', 0 },
			{ 'EHF', '[[Federación Europea de Balonmano|EHF]]', 3573, 'n', 0 },
			{ 'IWF', '[[Federación Internacional de Halterofilia|IWF]]', 3667, 'n', 0 },
			{ 'IOF', '[[Federación Internacional de Orientación|IOF]]', 3672, 'n', 0 },
			{ 'ISSF', '[[Federación Internacional de Tiro Deportivo|ISSF]]', 2730, 'n', 0 },
			{ 'FIVB', '[[Federación Internacional de Voleibol|FIVB]]', 2801, 'n', 0 },
			{ 'CEV', '[[Confederación Europea de Voleibol|CEV]]', 3725, 'n', 0 },
			{ 'ICF', '[[Federación Internacional de Piragüismo|ICF]]', 3689, 'n', 0 },
			{ 'FISA', '[[Federación Internacional de Sociedades de Remo|FISA]]', 2091, 'n', 0 },
			{ 'IFSC', '[[Federación Internacional de Escalada Deportiva|IFSC]]', 3690, 'n', 0 },
			{ 'NLL', '[[National Lacrosse League|NLL]]', 3955, 'n', 0 },
			{ 'PGA', '[[Professional Golfers Association of America|PGA]]', 2811, 'n', 0 },
			{ 'LPGA', '[[LPGA]]', 2810, 'n', 0 },
			{ 'FIBA', '[[Federación Internacional de Baloncesto|FIBA]]', 3542, 'n', 0 },
			{ 'Euroliga', '[[Euroliga]]', 3536, 'n', 0 },
			{ 'WNBA', '[[WNBA]]', 3588, 'n', 0 },
			{ 'NBA', '[[NBA]]', 3647, 'n', 0 },
			{ 'ACB', '[[Asociación de Clubs de Baloncesto|ACB]]', 3525, 'n', 0 },
			{ 'Entr. ACB', '[[Asociación de Clubs de Baloncesto|Entrenador ACB]]', 6297, 'n', 0 },
		},
	},
    {
		title = 'Cine',
		group = {
			{ 'FilmAffinity', '[[FilmAffinity]]', 480, 'n', 0 },
			{ 'IMDb', '[[Internet Movie Database|IMDb]]', 345, 'n', 0 },
			{ 'Óscar', '[[Premios Óscar|Óscar]]', 6145, 'n', 0 },
			{ 'AFI', '[[AFI Catalog of Feature Films|AFI]]', 3593, 'n', 0 },
			{ 'Allcinema', '[[Allcinema]]', 2465, 'n', 0 },
			{ 'AllMovie', '[[AllMovie]]', 1562, 'n', 0 },
			{ 'AlloCiné', '[[AlloCiné]]', 1265, 'n', 0 },
			{ 'BFI', '[[British Film Institute|BFI]]', 2703, 'n', 0 },
			{ 'Box Office Mojo', '[[Box Office Mojo]]', 1237, 'n', 0 },
			{ 'ICAA película', '[[Instituto de la Cinematografía y de las Artes Audiovisuales|ICAA]]', 5128, 'n', 1 },			
		},
	},
	{
		title = 'Empresarios',
		group = {
			{ 'Bloomberg', '[[Bloomberg L.P.|Bloomberg]]', 3052, 'n', 0 },
			{ 'Crunchbase', '[[Crunchbase]]', 2087, 'n', 0 },
		},
	},
	{
		title = 'Informática',
		group = {
			{ 'TOP500', 'TOP500', 7307, 'n', 0 },
			{ 'Arch', 'Arch Linux', 3454, 'n', 0 },
			{ 'AUR', 'AUR', 4162, 'n', 0 },
			{ 'Debian', 'Debian', 3442, 'n', 0 },
			{ 'Fedora', 'Fedora', 3463, 'n', 0 },
			{ 'FSD', 'Free Software Directory', 2537, 'n', 0 },
			{ 'Gentoo', 'Gentoo', 3499, 'n', 0 },
			{ 'OpenHub', '[[Open Hub]]', 1972, 'n', 0 },
			{ 'PyPI', '[[PyPI]]', 5568, 'n', 0 },
			{ 'Snap', 'Snap', 4435, 'n', 0 },
			{ 'Ubuntu', 'Ubuntu', 3473, 'n', 0 },
		}
	},
	{
		title = 'Bases de datos taxonómicas',
		group = {
			{ 'Algabase', '[[AlgaeBase]]', 1348, 'n', 0 },
			{ 'ADW', '[[Animal Diversity Web|ADW]]', 4024, 'n', 0 },
			{ 'AmphibiaWeb', '[[AmphibiaWeb]]', 5036, 'n', 0 },
			{ 'BOLD', 'BOLD', 3606, 'n', 0 },
			{ 'APD', '[[African Plant DB]]', 2036, 'n', 0 },
			{ 'Avibase', '[[Avibase]]', 2026, 'n', 0 },
			{ 'BHL', '[[Biodiversity Heritage Library|BHL]]', 687, 'n', 0 },
			{ 'BioLib', '[[BioLib]]', 838, 'n', 0 },
			{ 'BirdLife', '[[BirdLife International|BirdLife]]', 5257, 'n', 0 },
			{ 'CatalogueOfLife', '[[Catalogue of Life]]', 3088, 'n', 0 },
			{ 'CONABIO', '[[Comisión Nacional para el Conocimiento y Uso de la Biodiversidad|CONABIO]]', 4902, 'n', 0 },
			{ 'Dyntaxa', '[[Dyntaxa]]', 1939, 'n', 0 },
			{ 'eBird', '[[eBird]]', 3444, 'n', 0 },
			{ 'EOL', '[[Enciclopedia de la vida|EOL]]', 830, 'n', 0 },
			{ 'EUNIS', '[[European Nature Information System|EUNIS]]', 6177, 'n', 0 },
			{ 'FaunaEuropaea', '[[Fauna Europaea]]', 1895, 'n', 0 },
			{ 'FishBase', '[[FishBase]]', 938, 'n', 0 },
			{ 'FloraBase', '[[FloraBase]]', 3101, 'n', 0 },
			{ 'FOC', '[[Flora of China|Fl. China]]', 1747, 'n', 0 },
			{ 'GBIF', '[[Global Biodiversity Information Facility|GBIF]]', 846, 'n', 0 },
			{ 'GlobalSpecies', 'GlobalSpecies', 6433, 'n', 0 },
			{ 'GRIN', '[[Germplasm Resources Information Network|GRIN]]', 1421, 'url', 0 },
			{ 'IBC', [[Internet Bird Collection|IBC]], 3099, 'n', 0 },
			{ 'iNaturalist', [[iNaturalist]], 3151, 'n', 0 },
			{ 'IndexFungorum', '[[Index Fungorum]]', 1391, 'n', 0 },
			{ 'IOBIS', 'OBIS', 6754, 'n', 0 },
			{ 'IPNI', '[[Índice Internacional de Nombres de las Plantas|IPNI]]', 961, 'n', 0 },
			{ 'ITIS', '[[Sistema Integrado de Información Taxonómica|ITIS]]', 815, 'n', 0 },
			{ 'LPSN', '[[Listado de nombres procariotas con posición en nomenclatura|LPSN]]', 1991, 'url', 0 },
			{ 'MSW', '[[Mammal Species of the World|MSW]]', 959, 'n', 0 },
			{ 'MycoBank', '[[MycoBank]]', 962, 'n', 0 },
			{ 'NCBI', '[[Centro Nacional para la Información Biotecnológica|NCBI]]', 685, 'n', 0 },
			{ 'FossilWorks', '[[Paleobiology Database]]', 842, 'n', 0 },
			{ 'PlantList', '[[The Plant List|PlantList]]', 1070, 'n', 0 },
			{ 'SpeciesPlus', 'Species+', 2040, 'n', 0 },
			{ 'Taxonomicon', 'Taxonomicon', 7066, 'n', 0 },
			{ 'Tropicos', '[[W3TROPICOS]]', 960, 'n', 0 },
			{ 'UICN', '[[Unión Internacional para la Conservación de la Naturaleza|UICN]]', 627, 'n', 0 },
			{ 'USDAP', '[[Departamento de Agricultura de los Estados Unidos|USDA Plants]]', 1772, 'n', 0 },
			{ 'VASCAN', 'VASCAN', 1745, 'n', 0 },
			{ 'WoRMS', '[[Registro Mundial de Especies Marinas|WoRMS]]', 850, 'n', 0 },
			{ 'uBio', 'uBio', 4728, 'n', 0 },
			{ 'Xeno-canto', '[[Xeno-canto]]', 2426, 'n', 0 },
			{ 'Zoobank', '[[Zoobank]]', 1746, 'n', 0 },
		},
	},
	{
		title = 'Identificadores médicos',
		group = {
			{ 'DOID', 'DOID', 699, 'n', 0 },
			{ 'CIE9', '[[CIE-9]]', 493, 'n', 0 },
			{ 'CIE10', '[[CIE-10]]', 494, 'n', 0 },
			{ 'CIE9MC', '[[CIE-9-MC]]', 1692, 'n', 0 },
			{ 'CIE10MC', 'CIE-10-MC', 4229, 'n', 0 },
			{ 'CIEO', '[[CIE-O]]', 563, 'n', 0 },
			{ 'CIAP2', '[[Clasificación Internacional de Atención Primaria|CIAP-2]]', 667, 'n', 0 },
			{ 'OMIM', '[[Herencia Mendeliana en el Hombre|OMIM]]', 492, 'n', 0 },
			{ 'DSM IV', '[[Manual diagnóstico y estadístico de los trastornos mentales|DSM IV]]', 663, 'n', 0 },
			{ 'DSM 5', '[[DSM 5|DSM-5]]', 1930, 'n', 0 },
			{ 'DiseasesDB', '[[Diseases Database|DiseasesDB]]', 557, 'n', 0 },
			{ 'MedlinePlus', '[[MedlinePlus]]', 604, 'n', 0 },
			{ 'eMedicine', '[[eMedicine]]', 673, 'n', 0 },
			{ 'MeSH', '[[Medical Subject Headings|MeSH]]', 486, 'n', 0 },
			{ 'MeSHdq', 'MeSH D/Q', 9340, 'y', 0 },
			{ 'DeCS', '[[Descriptores en Ciencias de la Salud|DeCS]]', 9272, 'n', 0 },
			{ 'Orphanet', '[[Orphanet]]', 1550, 'n', 0 },
			{ 'TA98', '[[Terminología Anatómica|TA]]', 1323, 'n', 1 },
			{ 'FMA', '[[Foundational Model of Anatomy|FMA]]', 1402, 'n', 0 },
			{ 'UMLS', 'UMLS', 2892, 'n', 0 },
			{ 'GeneReviews', 'GeneReviews', 668, 'n', 0 },
			{ 'NumE', '[[Número E]]', 628, 'n', 0 },
		}
	},
	{
		title = 'Identificadores químicos',
		group = {
			{ 'CAS', '[[Número CAS]]', 231, 'n', 0 },
			{ 'EINECS', '[[EINECS|Números EINECS]]', 232, 'n', 0},
			{ 'ATC', '[[Código ATC]]', 267, 'n', 0 },
			{ 'RTECS', '[[RTECS]]', 657, 'n', 0 },
			{ 'ChEBI', '[[ChEBI]]', 683, 'n', 0 },
			{ 'ChEMBL', '[[ChEMBL]]', 592, 'n', 0 },
			{ 'ChemSpider', '[[ChemSpider]]', 661, 'n', 0 },
			{ 'DrugBank', '[[DrugBank]]', 715, 'n', 0 },
			{ 'PubChem', '[[PubChem]]', 662, 'n', 0 },
			{ 'UNII', '[[Unique Ingredient Identifier|UNII]]', 652, 'n', 0 },
			{ 'KEGG', '[[KEGG]]', 665, 'n', 0 },
			{ 'SMILES', '[[SMILES]]', 233, 'y', 0 },
			{ 'InChI', '[[International Chemical Identifier|InChI]]', 234, 'y', 0 },
			{ 'InChIKey', 'InChI key', 235, 'y', 0 },
		}
	},
	{
		title = 'Identificadores biológicos',
		group = {
			{ 'MGI', '[[Mouse Genome Informatics|MGI]]', 231, 'n', 0 },
			{ 'HomoloGene', '[[HomoloGene]]', 593, 'n', 0 },
			{ 'UniProt', '[[UniProt]]', 352, 'n', 0 },
		}
	},
	{
		title = 'Identificadores astronómicos',
		group = {
			{ 'COSPAR', 'COSPAR', 247, 'n', 0 },
			{ 'SCN', '[[Satellite Catalog Number|SCN]]', 377, 'n', 0 },
			{ 'NSSDCA', '[[International Designator|NSSDCA]]', 8913, 'n', 0 }
		}
	},
	{
		title = 'Ontologías',
		group = {
			{ 'IEV', 'Número IEV', 8855, 'n', 0 },
			{ 'OUM2', 'OUM 2.0', 8769, 'n', 0 }
		}
	}
}
-- -- Example row: --
-- conf.databases[2] = {}
-- conf.databases[2].name = 'External links'
-- conf.databases[2].list = {
-- 	{
-- 		title = '',
-- 		group = {
-- 			{ 'Website', 'Website', 856, 'n', 0 },
-- 		},
-- 	},
-- }

--In this order: alternate name, name of parameter from databases table
conf.aliases = {
	{ 'Wd', 'Wikidata' },
	{ 'PND', 'GND' },
	{ 'Commonscat', 'Commons' },
}

local function getCatForId( parameter, category )
	local title = mw.title.getCurrentTitle()
	local namespace = title.namespace
	if category == 0 then
		return ''
	elseif category == 1 then
		category = parameter
	end
	if namespace == 0 then
		return '[[Categoría:Wikipedia:Artículos con identificadores ' .. category .. ']]\n'
	elseif namespace == 2 and not title.isSubpage then
		return '[[Categoría:Wikipedia:Páginas de usuario con identificadores ' .. category .. ']]\n'
	else
		return '[[Categoría:Wikipedia:Páginas misceláneas con identificadores ' .. category .. ']]\n'
	end
end

function getIdsFromSitelinks( itemId, property )
	local ids = {}
	local siteLink = itemId and mw.wikibase.getSitelink( itemId, property )
	if siteLink then
		table.insert( ids, siteLink )
	end
	return ids
end

function getIdsFromWikidata( itemId, property )
	local ids = {}
	local declaraciones = mw.wikibase.getBestStatements(itemId, property)
	
	for _, statement in pairs( declaraciones) do
		if statement.mainsnak.datavalue then
			table.insert( ids, statement.mainsnak.datavalue.value )
		end
	end
	return ids
end

function getLink( property, val, mask )
	local link = ''
	if mw.ustring.find( val, '//' ) then
		link = val
	else
		if type(property) == 'number' then
			local entityObject = mw.wikibase.getEntityObject('P'..property)
			local dataType = entityObject.datatype
			if dataType == 'external-id' then
				local allStatements = entityObject:getAllStatements('P1630')
				if allStatements then
					for pos = 1, #allStatements, 1 do
						local q = allStatements[pos].qualifiers
						if q and q.P407 and q.P407[1].datavalue.value.id == 'Q1321' then
							link = allStatements[pos].mainsnak.datavalue.value
						end
					end
				end
				if link == '' then
					local formatterURL = entityObject:getBestStatements('P1630')[1]
					if formatterURL then
						link = formatterURL.mainsnak.datavalue.value
					else
						local formatterURL = entityObject:getBestStatements('P3303')[1]
						if formatterURL then link = formatterURL.mainsnak.datavalue.value end
					end
				end
			elseif dataType == 'url' then
				local subjectItem = entityObject:getBestStatements('P1629')[1]
				if subjectItem then
					local officialWebsite = mw.wikibase.getBestStatements(subjectItem.mainsnak.datavalue.value.id, 'P856')[1]
					if officialWebsite then
						link = officialWebsite.mainsnak.datavalue.value 
					end
				end
			elseif dataType == 'string' then
				local formatterURL = entityObject:getBestStatements('P1630')[1]
				if formatterURL then
					link = formatterURL.mainsnak.datavalue.value
				else
					local formatterURL = entityObject:getBestStatements('P3303')[1]
					if formatterURL then
						link = formatterURL.mainsnak.datavalue.value
					else
						local subjectItem = entityObject:getBestStatements('P1629')[1]
						if subjectItem then
							local officialWebsite = mw.wikibase.getBestStatements(subjectItem.mainsnak.datavalue.value.id,'P856')[1]
							if officialWebsite then
								link = officialWebsite.mainsnak.datavalue.value
							end
						end
					end
				end
			end
		elseif type(property) == 'string' then
			link = property
		end
	end
	link = mw.ustring.gsub(link, '^[Hh][Tt][Tt][Pp]([Ss]?)&#58;//', 'http%1://') -- fix wikidata URL
	if type(mask) == 'function' then
		return mask( val, link, property )
	end
	link = mw.ustring.gsub(link, '$1', mw.ustring.gsub( mw.ustring.gsub( val, '%%', '%%%%' ), ' ', '%%%%20' ) or val )
	if mw.ustring.find( link, '//' ) then
		if type(mask) == 'string' then
			link = cleanLink( link, 'PATH' )
			if mask == 'y' then
				return '['..link..' ID]'
			elseif mask == 'n' then
				return '['..link..' '..val..']'
			end
			return '['..link..' '..mask..']'
		end
	elseif link == '' then
		return val
	else
		return '[['..link..'|'..val..']]'
	end
end

local function createRow( id, label, rawValue, link, withUid )
	if link then
		if label and label ~= '' then label = '<span style="white-space:nowrap;">'..label  .. ':</span> ' end
		if withUid then
			return '* ' .. label .. '<span class="uid">' .. link .. '</span>\n'
		else
			return '* ' .. label .. link .. '\n'
		end
	else
		return '* <span class="error">El ' .. id .. ' id ' .. rawValue .. ' no es válido</span>[[Categoría:Wikipedia:Páginas con problemas en el control de autoridades]]\n'
	end
end

local function copyTable(inTable)
	if type(inTable) ~= 'table' then return inTable end
	local outTable = setmetatable({}, getmetatable(inTable))
	for key, value in pairs (inTable) do outTable[copyTable(key)] = copyTable(value) end
	return outTable
end

local function splitLccn( id )
	if id:match( '^%l%l?%l?%d%d%d%d%d%d%d%d%d?%d?$' ) then
		id = id:gsub( '^(%l+)(%d+)(%d%d%d%d%d%d)$', '%1/%2/%3' )
	end
	if id:match( '^%l%l?%l?/%d%d%d?%d?/%d+$' ) then
		return mw.text.split( id, '/' )
	end
	return false
end

local p = {}

function p.authorityControl( frame )
	local pArgs = frame:getParent().args
	local parentArgs = copyTable(pArgs)
	local stringArgs = false
	local fromForCount, itemCount, rowCount = 1, 0, 0
	local mobileContent = ''
	--Cleanup args
	for k, v in pairs( pArgs ) do
		if type(k) == 'string' then
			--make args case insensitive
			local lowerk = mw.ustring.lower(k)
			if not parentArgs[lowerk] or parentArgs[lowerk] == '' then
				parentArgs[lowerk] = v
				parentArgs[k] = nil
			end
			--remap abc to abc1
			if not mw.ustring.find(lowerk, '%d$') then --if no number at end of param
				if not parentArgs[lowerk..'1'] or parentArgs[lowerk..'1'] == '' then
					parentArgs[lowerk..'1'] = v
					parentArgs[lowerk] = nil
				end
			end
			if v and v ~= '' then
				--find highest from param
				if mw.ustring.sub(lowerk,1,4) == 'from' then
					local fromNumber = tonumber(mw.ustring.sub(lowerk,5,-1))
					if fromNumber and fromNumber >= fromForCount then fromForCount = fromNumber end
				elseif mw.ustring.sub(lowerk,1,3) == 'for' then
					local forNumber = tonumber(mw.ustring.sub(lowerk,4,-1))
					if forNumber and forNumber >= fromForCount then fromForCount = forNumber end
				elseif mw.ustring.lower(v) ~= 'no' and lowerk ~= 'for' then
					stringArgs = true
				end
			end
		end
	end

	--Setup navbox
	local navboxParams = {
		name  = 'Control de autoridades',
		bodyclass = 'hlist',
		groupstyle = 'width: 12%; text-align:center;',
	}
	for f = 1, fromForCount, 1 do
		local title = {}
		--cleanup parameters
		if parentArgs['from'..f] == '' then parentArgs['from'..f] = nil end
		if parentArgs['for'..f] == '' then parentArgs['for'..f] = nil end
		--remap aliases
		for _, a in pairs( conf.aliases ) do
			local alias, name = mw.ustring.lower(a[1]), mw.ustring.lower(a[2])
			if parentArgs[alias..f] and not parentArgs[name..f] then
				parentArgs[name..f] = parentArgs[alias..f]
				parentArgs[alias..f] = nil
			end
		end

		--Fetch Wikidata item
		local itemId = parentArgs['from'..f] or mw.wikibase.getEntityIdForCurrentPage()
		local label = itemId and (mw.wikibase.getSitelink(itemId) or mw.wikibase.getLabel(itemId)) or ''
		if label and label ~= '' then
			title = mw.title.new(label)
			if not title then title = mw.title.getCurrentTitle() end
		else
			title = mw.title.getCurrentTitle()
		end

		if (not parentArgs['wikidata'..f] or parentArgs['wikidata'..f] == '') and (title.namespace == 0 or title.namespace == 104) then
			parentArgs['wikidata'..f] = parentArgs['from'..f] or itemId or ''
		end
		if title.namespace == 0 or title.namespace == 104 or stringArgs then --Only in the main namespaces or if there are manual overrides

			if fromForCount > 1 and #conf.databases > 1 then
				if parentArgs['for'..f] and parentArgs['for'..f] ~= '' then
					navboxParams['list'..(rowCount + 1)] = "'''" .. parentArgs['for'..f] .. "'''"
				else
					navboxParams['list'..(rowCount + 1)] = "'''" .. title.text .. "'''"
				end
				navboxParams['list'..(rowCount + 1)..'style'] = 'background-color: #ddf;'
				rowCount = rowCount + 1
			end
			for _, db in pairs( conf.databases ) do
				if db.list and #db.list > 0 then
					local listElements = {}
					for n, gr in pairs( db.list ) do
						local groupElements = {}
						if gr.group and #gr.group > 0 then
							for _, params in pairs( gr.group ) do
								local id = mw.ustring.lower( params[1] )
								-- Wikidata fallback if requested
								if itemId and params[3] ~= 0 and (not parentArgs[id..f] or parentArgs[id..f] == '') then
									local wikidataIds = {}
									if type( params[3] ) == 'function' then
										wikidataIds = params[3]( itemId )
									elseif type( params[3] ) == 'string' then
										wikidataIds = getIdsFromSitelinks(itemId, params[3] )
									else
										wikidataIds = getIdsFromWikidata( itemId, 'P' .. params[3] )
									end
									if wikidataIds[1] then
										parentArgs[id..f] = wikidataIds[1]
									end
								end
								-- Worldcat
								if id == 'issn' and parentArgs['worldcatid'..f] and parentArgs['worldcatid'..f] ~= '' then -- 'issn' is the first element following the 'wikidata' item
									table.insert( groupElements, createRow( id, '', parentArgs['worldcatid'..f], '[//www.worldcat.org/identities/' .. parentArgs['worldcatid'..f] .. ' WorldCat]', false ) ) --Validation?
								elseif id == 'viaf' and parentArgs[id..f] and string.match( parentArgs[id..f], '^%d+$' ) and not parentArgs['worldcatid'..f] then -- Hackishly copy the validation code; this should go away when we move to using P1793 and P1630
									table.insert( groupElements, createRow( id, '', parentArgs[id..f], '[//www.worldcat.org/identities/containsVIAFID/' .. parentArgs[id..f] .. ' WorldCat]', false ) )
								elseif id == 'lccn' and parentArgs[id..f] and parentArgs[id..f] ~= '' and not parentArgs['viaf'..f] and not parentArgs['worldcatid'..f] then
									local lccnParts = splitLccn( parentArgs[id..f] )
									if lccnParts and lccnParts[1] ~= 'sh' then
										table.insert( groupElements, createRow( id, '', parentArgs[id..f], '[//www.worldcat.org/identities/lccn-' .. lccnParts[1] .. lccnParts[2] .. '-' .. lccnParts[3] .. ' WorldCat]', false ) )
									end
								end

								local val = parentArgs[id..f]
								if val and val ~= '' and mw.ustring.lower(val) ~= 'no' and params[3] ~= 0 then
									local link
									if type( params[3] ) == 'function' then
										link = val
									else
										link = getLink( params[3], val, params[4] )
									end
									if link and link ~= '' then
										table.insert( groupElements, createRow( id, params[2], val, link, true ) .. getCatForId( params[1], params[5] or 0 ) )
										itemCount = itemCount + 1
									end
								end
							end
							if #groupElements > 0 then
								if gr.title and gr.title ~= '' then
									table.insert( listElements, "* '''"..gr.title.."'''\n" )
								end
								table.insert( listElements, table.concat( groupElements ) )
								if n == 1 and #groupElements > 1 then
									table.insert( listElements, "\n----\n" )
								end
								-- mobile version
								if n == 1 then
									mobileContent = table.concat( groupElements )
								end
							end
						end
					end
					-- Generate navbox title
					if #listElements > 0 then
						if fromForCount > 1 and #conf.databases == 1 then
							if parentArgs['for'..f] and parentArgs['for'..f] ~= '' then
								navboxParams['group'..(rowCount + 1)] = "''" .. parentArgs['for'..f] .. "''"
							else
								navboxParams['group'..(rowCount + 1)] = "''" .. title.text .. "''"
							end
						else
							navboxParams['group'..(rowCount + 1)] = db.name or ''
						end
						navboxParams['list'..(rowCount + 1)] = table.concat( listElements )
						rowCount = rowCount + 1
					end
				end
			end
		end
	end
	if rowCount > 0 then
		local Navbox = require('Módulo:Navbox')
		if fromForCount > 1 then
			--add missing names
			for r = 1, rowCount, 1 do
				if navboxParams['group'..r] == '' then
					navboxParams['group'..r] = "''" .. mw.wikibase.getEntity(parentArgs['wikidata'..r]):getLabel().."''"
				end
			end
			if fromForCount > 2 then
				navboxParams['navbar'] = 'plain'
			else
				navboxParams['state'] = 'off'
				navboxParams['navbar'] = 'off'
			end
		end
		local mainCategories = ''
		if stringArgs then
			mainCategories = mainCategories .. '[[Categoría:Wikipedia:Páginas que utilizan control de autoridades con parámetros]]\n'
		end
		if itemCount > 13 then
			if itemCount > 30 then
				itemCount = 'más de 30'
			end
			mainCategories = mainCategories .. '[[Categoría:Wikipedia:Control de autoridades con ' .. itemCount .. ' elementos]]\n'
		end
		navboxParams['style'] = 'width: inherit';
		return frame:extensionTag{ name = 'templatestyles', args = { src = 'Plantilla:Control de autoridades/styles.css' } }
			.. tostring(
				mw.html.create( 'div' )
					:addClass( 'mw-authority-control' )
					:wikitext( Navbox._navbox( navboxParams ) )
					:done()
				:tag('div')
					:addClass( 'mw-mf-linked-projects' )
					:addClass( 'hlist' )
					:newline()
					:wikitext( mobileContent )
					:done()
				:done()
			)
			.. mainCategories
	else
		return ''
	end
end

return p