Page MenuHomePhabricator

Switch Portugal to Wikidata at the Monuments Database
Open, Needs TriagePublic

Description

Old database is quite outdated and corrupt, we have moved away fro it into Wikidata (monument lists being generated in Listeria)

Basically, whatever has wdt:P2186 is fine to come in the dataset.

The ID we are using in WLM is the Qid, but we also have a unique WLM ID available, just in case (and it is also useful to help generating our monument lists)

This is an example of the query we are using to generate the lists in Listeria, for a given region/district (for thw whole country use P17=Q45):

SELECT DISTINCT ?item ?itemLabel ?idwlm ?localLabel ?municipioLabel ?fonte ?cat ?cats ?button (GROUP_CONCAT(DISTINCT ?tipoLabel ;separator=", ") AS ?tipos) 
(GROUP_CONCAT(DISTINCT ?classLabel ;separator=", ") AS ?classes) 
WITH {
  SELECT DISTINCT ?item ?local ?municipio  WHERE {
    { ?item wdt:P131 ?local.
     ?local wdt:P131 ?municipio. 
     ?municipio wdt:P131 wd:Q25263. } # itens ao nível de freguesia
    UNION
    { ?item wdt:P131 ?local.
     ?local wdt:P131 wd:Q26253. } # itens ao nível de concelho
    UNION
    { ?item wdt:P131 wd:Q26253. } # itens ao nível da região
    
  }
} as %results
WHERE {           
  INCLUDE %results
  { ?item wdt:P2186 ?idwlm. } # IDWLM
  OPTIONAL { ?item wdt:P31 ?tipo. } # Tipo
  OPTIONAL { ?item wdt:P1435 ?class. } # Classificação
  OPTIONAL { ?item wdt:P1702 ?id1. } # ID DGPC 
  OPTIONAL { ?item wdt:P1700 ?id2. } # ID SIPA
  {BIND (CONCAT("[www.patrimoniocultural.gov.pt/pt/patrimonio/patrimonio-imovel/pesquisa-do-patrimonio/classificado-ou-em-vias-de-classificacao/geral/view/",?id1," ","IGESPAR]") as ?url1)}
  {BIND (CONCAT("[http://www.monumentos.gov.pt/Site/APP_PagesUser/SIPA.aspx?id=",?id2," ","SIPA]") as ?url2)}
  {BIND (CONCAT(COALESCE( ?url1,''), COALESCE( CONCAT(IF (BOUND (?url1),'<br>',''), ?url2),'')) AS ?fonte)}
  OPTIONAL {?item wdt:P373 ?cat.}
  {BIND (CONCAT('Images from Wiki Loves Monuments 2019 in Portugal - Madeira',IF(BOUND(?cat),CONCAT('{{!}}',?cat),'')) AS ?cats)}
  BIND(SUBSTR(STR(?item), 32 ) AS ?id)
  OPTIONAL { ?item schema:description ?descr.
  FILTER((LANG(?descr)) = 'pt') }
  BIND(CONCAT('<span class=', '\"', 'plainlinks', '\"', '>[https://commons.wikimedia.org/w/index.php?title=Special:UploadWizard&campaign=wlm-pt&id=', 
              STR(?id), '&descriptionlang=pt&description={{urlencode:', CONCAT(COALESCE(?itemLabel, ''),' - ',COALESCE(?descr, '')), '}}', '&categories={{urlencode:', ?cats, '}}&captionlang=pt&caption={{urlencode:', CONCAT(COALESCE(?itemLabel, ''),' - ',COALESCE(?descr, '')), '}} {{Clickable button|color=blue|Enviar Foto}}]</span>') AS ?button)

  
  SERVICE wikibase:label { bd:serviceParam wikibase:language 'pt,pt-br,en'. 
                         ?class rdfs:label ?classLabel.
                         ?tipo rdfs:label ?tipoLabel.
                         ?item rdfs:label ?itemLabel.
                         ?local rdfs:label ?localLabel.
                         ?municipio rdfs:label ?municipioLabel. 
}    
}
GROUP BY ?item ?itemLabel ?idwlm ?localLabel ?municipioLabel ?id1 ?fonte ?cat ?cats ?button
ORDER BY ?municipioLabel ?localLabel ?itemLabel

If you want a specific query, please tell me

Preliminary mapping

{
    "country": "pt",
    "lang": "pt",
    "description": "Cultural heritage sites in Portugal in Portuguese",
    "type": "sparql",
    "project": "",
    "table": "monuments_pt-wd_(pt)",
    "commonsTemplate": "MonumentIDPortugal",
    "commonsTrackerCategory": "Cultural heritage monuments in Portugal with known IDs",
    "commonsCategoryBase": "Cultural heritage monuments in Portugal",
    "unusedImagesPage": "",
    "imagesWithoutIdPage": "",
    "missingCommonscatPage": "",
    "sparql": "",
    "sql_lang": "Portuguese # Wikidata",
    "sql_country": "Portugal",
    "sql_data": {
        "dataset": {
            "value": "pt-wd",
            "type": "Text"
        },
        "lang": {
            "value": "pt",
            "type": "Text"
        },
        "adm0": {
            "value": "pt",
            "type": "Text"
        }
    }
}

Related Objects

Event Timeline

Thanks. The following should work as our sparql string: https://w.wiki/7ke

Could you also add information about:

  • the id-template you use on Commons (and any parameters this expects)
  • the base category you use on Commons.
  • when do you use the Qid and when do you use the unique WLM_ID?
  • where (on which wiki and as subpages to which page) do you want the reports to be outputted? (since the old ones are all labelled IGESPAR I'm assuming they should not be re-used).

Do the ids in the old lists connect to the new ids in any way?

Thanks, the sparql query seems to be OK.

id-template: MonumentIDPortugal (https://commons.wikimedia.org/wiki/Template:MonumentIDPortugal), expects Qid (wikidata)
Base category: https://commons.wikimedia.org/wiki/Category:Cultural_heritage_monuments_in_Portugal_with_known_IDs (I think?)
Qid is the general ID, WLM ID is an internal ID to verify the monument is indeed classified/listed (we do not have a national ID)
Wikis: Commons and Wikipedia would be nice. Would it also be possible to output them to our internal wiki at pt.wikimedia.org?
Subpages: We need to find a proper place for them, can this part wait some days?

"Do the ids in the old lists connect to the new ids in any way?" - sort of. IDs starting with 970 are SIPA-ID, less the 97 and the "0"s, but they are always overruled by DGPC (IGESPAR) IDs when they are available. "DGPC-" IDs are the general IGESPAR IDs, which do not start with 970, 980 and 990. Old IDs starting with 980 and 990 at the old database belong to the autonomous regions, and cannot be linked to the new ones in any reliable way, since some numbers were changed, and many don't have any official number. But we have exported that database already to wikidata from the copy we had from 2011, so it would have the same information already there (but updated)

Wikis: Commons and Wikipedia would be nice. Would it also be possible to output them to our internal wiki at pt.wikimedia.org?
Subpages: We need to find a proper place for them, can this part wait some days?

The lists/reports can only be outputted to a single wiki. Either of the three should be possible although id recommend not using the chapter wiki as that decreases the chances of them getting attention between competitions. For the seame reason I would recomend against making it a subpage under Wikipédia:Wiki_Loves_Monuments_2019/Portugal.

The reports from the old lists are outputted to pt:Wikipédia:Projetos/Património de Portugal/Fotos IGESPAR não usadas and User:Multichill/IGESPAR without an ID.

While subpages of Wikipédia:Projetos/Património_de_Portugal is probably the way to go we could start out with something like the following in the meantime:

  • User:ErfgoedBot/Fotos de patrim√≥nio portugu√™s n√£o usadas
  • User:ErfgoedBot/Fotos de patrim√≥nio portugu√™s sem identifica√ß√£o

Change 534974 had a related patch set uploaded (by Lokal Profil; owner: Lokal Profil):
[labs/tools/heritage@master] [WIP]Add pt-wd_pt as sparql harvest

https://gerrit.wikimedia.org/r/534974

Local harvest works fine.

@Darwinius
I've set this up to produce reports at

these can be change to another page on pt.wikipedia if you want.

Change 534974 merged by jenkins-bot:
[labs/tools/heritage@master] Add pt-wd_pt as sparql harvest

https://gerrit.wikimedia.org/r/534974

Mentioned in SAL (#wikimedia-cloud) [2019-09-09T22:00:22Z] <JeanFred> Deploy latest from Git master: 109be22 (T231727)

This open task is tagged with Wiki-Loves-Monuments 2019 which was a year ago. If this task was/is resolved, then please update the task status. If this task was not resolved but is still valid, then please update the project tags to either general Wiki-Loves-Monuments, or to the Wiki-Loves-Monuments (2020) project tag if you plan to actively work on this task in the year 2020. Thanks a lot!

Boldly removing WLM 2019 and setting Wiki-Loves-Monuments (2020). (Feel free to remove or correct.)