Difference between revisions of "Factgrid2024-09-19"

From BITPlan cr Wiki
Jump to navigation Jump to search
(Created page with "= Queries = <source lang='yaml'> # Queries # Wolfgang Fahl 2024-09-19 'IlluminatiNoImage': sparql: | # Query for items related to Illuminati without an associated image...")
 
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
 +
 
= Queries =
 
= Queries =
 
<source lang='yaml'>
 
<source lang='yaml'>
 +
# Queries
 +
# Wolfgang Fahl 2024-09-19
 
# Queries
 
# Queries
 
# Wolfgang Fahl 2024-09-19
 
# Wolfgang Fahl 2024-09-19
Line 15: Line 19:
 
     }
 
     }
 
'AntonGraffPortraitsWithImages':
 
'AntonGraffPortraitsWithImages':
 +
  param_list:
 +
    - name: limit
 +
      type: int
 +
      default_value: 15
 
   sparql: |
 
   sparql: |
 
     # Query for portraits by Anton Graff with optional image content and Wikimedia Commons links
 
     # Query for portraits by Anton Graff with optional image content and Wikimedia Commons links
Line 30: Line 38:
 
     }
 
     }
 
     ORDER BY ?Portrait
 
     ORDER BY ?Portrait
 +
    LIMIT 15
 +
'Occupation Statistics':
 +
  sparql: |
 +
    # Query for general occupation statistics in FactGrid
 +
    # 2024-09-19
 +
    SELECT ?career ?careerLabel (COUNT(DISTINCT ?person) AS ?count)
 +
    WHERE {
 +
      ?person wdt:P165 ?career.
 +
      SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en". }
 +
    }
 +
    GROUP BY ?career ?careerLabel
 +
    ORDER BY DESC(?count)
 +
    LIMIT {{limit}}
 +
</source>
 +
<source lang='bash'>
 +
sparqlquery -d -qp factgrid.yaml -qn AntonGraffPortraitsWithImages -en factgrid -f mediawiki
 +
</source>
 +
=== named query AntonGraffPortraitsWithImages ===
 +
 +
== sparql ==
 +
<source lang='sparql'>
 +
# Query for portraits by Anton Graff with optional image content and Wikimedia Commons links
 +
# 2024-09-19
 +
SELECT ?Portrait ?PortraitLabel ?depicting ?depictingLabel ?Wikimedia_Commons_Item_image ?careerLabel ?OhdabLabel WHERE {
 +
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }
 +
  ?Portrait wdt:P121 wd:Q11225.
 +
  ?Portrait wdt:P611 wd:Q393235.
 +
  OPTIONAL { ?Portrait wdt:P705 ?depicting.
 +
  OPTIONAL { ?depicting wdt:P165 ?career.
 +
    OPTIONAL { ?career wdt:P1007 ?Ohdab . }
 +
            }
 +
          }
 +
  OPTIONAL { ?Portrait wdt:P189 ?Wikimedia_Commons_Item_image. }
 +
}
 +
ORDER BY ?Portrait
 +
LIMIT 15
 +
</source>
 +
 +
[https://database.factgrid.de/query/?query=%23%20Query%20for%20portraits%20by%20Anton%20Graff%20with%20optional%20image%20content%20and%20Wikimedia%20Commons%20links%0A%23%202024-09-19%0ASELECT%20%3FPortrait%20%3FPortraitLabel%20%3Fdepicting%20%3FdepictingLabel%20%3FWikimedia_Commons_Item_image%20%3FcareerLabel%20%3FOhdabLabel%20WHERE%20%7B%0A%20%20SERVICE%20wikibase%3Alabel%20%7B%20bd%3AserviceParam%20wikibase%3Alanguage%20%22de%22.%20%7D%0A%20%20%3FPortrait%20wdt%3AP121%20wd%3AQ11225.%0A%20%20%3FPortrait%20wdt%3AP611%20wd%3AQ393235.%0A%20%20OPTIONAL%20%7B%20%3FPortrait%20wdt%3AP705%20%3Fdepicting.%0A%20%20%20OPTIONAL%20%7B%20%3Fdepicting%20wdt%3AP165%20%3Fcareer.%0A%20%20%20%20OPTIONAL%20%7B%20%3Fcareer%20wdt%3AP1007%20%3FOhdab%20.%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20OPTIONAL%20%7B%20%3FPortrait%20wdt%3AP189%20%3FWikimedia_Commons_Item_image.%20%7D%0A%7D%0AORDER%20BY%20%3FPortrait%0ALIMIT%2015%0A try it!]
 +
=== result ===
 +
{| class="wikitable" style="text-align: left;"
 +
|+ <!-- caption -->
 +
|-
 +
! Portrait                                    !! PortraitLabel                                              !! depicting                                  !! depictingLabel                  !! Wikimedia_Commons_Item_image                                                                                !! careerLabel                    !! OhdabLabel
 +
|-
 +
| https://database.factgrid.de/entity/Q995392 || Anton Graff, Portrait 'Johann Christoph Adelung'            || https://database.factgrid.de/entity/Q140786 || Johann Christoph Adelung        || http://commons.wikimedia.org/wiki/Special:FilePath/Johann%20Christoph%20Adelung.jpg                        || Bibliothekar/in                || B 73324-107: Bibliothekar/in
 +
|-
 +
| https://database.factgrid.de/entity/Q995392 || Anton Graff, Portrait 'Johann Christoph Adelung'            || https://database.factgrid.de/entity/Q140786 || Johann Christoph Adelung        || http://commons.wikimedia.org/wiki/Special:FilePath/Johann%20Christoph%20Adelung.jpg                        || Lexikograf/in                  || B 91184-117: Lexikograf/in
 +
|-
 +
| https://database.factgrid.de/entity/Q995393 || Anton Graff, Portrait 'Philipp Karl von Alvensleben'        || https://database.factgrid.de/entity/Q249786 || Philipp von Alvensleben          || http://commons.wikimedia.org/wiki/Special:FilePath/Philipp%20Karl%20von%20Alvensleben.jpg                  || Hofmarschall                    || B 64194-502: Marschall/in (Hofmarschall/in)
 +
|-
 +
| https://database.factgrid.de/entity/Q995394 || Anton Graff, Portrait 'Anton von Sachsen'                  || https://database.factgrid.de/entity/Q234232 || Anton, König von Sachsen        ||                                                                                                            || König/in                        || B 75394-502: König/in - Adel
 +
|-
 +
| https://database.factgrid.de/entity/Q995395 || Anton Graff, Portrait 'Heinrich Friedrich Innocentius Apel' || https://database.factgrid.de/entity/Q996462 || Heinrich Friedrich Innocenz Apel || http://commons.wikimedia.org/wiki/Special:FilePath/H.%20F.%20I.%20Apel.jpg                                  || Bürgermeister/in                || B 71214-101: Bürgermeister/in
 +
|-
 +
| https://database.factgrid.de/entity/Q995395 || Anton Graff, Portrait 'Heinrich Friedrich Innocentius Apel' || https://database.factgrid.de/entity/Q996462 || Heinrich Friedrich Innocenz Apel || http://commons.wikimedia.org/wiki/Special:FilePath/H.%20F.%20I.%20Apel.jpg                                  || Hof- und Justizrat              || B 73184-503: Justizrat/-rätin - herrschaftliche/r
 +
|-
 +
| https://database.factgrid.de/entity/Q995395 || Anton Graff, Portrait 'Heinrich Friedrich Innocentius Apel' || https://database.factgrid.de/entity/Q996462 || Heinrich Friedrich Innocenz Apel || http://commons.wikimedia.org/wiki/Special:FilePath/H.%20F.%20I.%20Apel.jpg                                  || Stadtrichter/in, Ratsrichter/in || B 73154-505: Stadtrichter/in, Ratsrichter/in
 +
|-
 +
| https://database.factgrid.de/entity/Q995395 || Anton Graff, Portrait 'Heinrich Friedrich Innocentius Apel' || https://database.factgrid.de/entity/Q996462 || Heinrich Friedrich Innocenz Apel || http://commons.wikimedia.org/wiki/Special:FilePath/H.%20F.%20I.%20Apel.jpg                                  || Baumeister                      || B 31193-107: Baumeister/in
 +
|-
 +
| https://database.factgrid.de/entity/Q995396 || Anton Graff, Portrait 'Detmar Basse'                        || https://database.factgrid.de/entity/Q996465 || Detmar Basse                    || http://commons.wikimedia.org/wiki/Special:FilePath/Anton_Graff_Basse_Kaufmann_aus_Frankfurt.jpg            || Diplomat/in                    || B 73294-523: Diplomat/in
 +
|-
 +
| https://database.factgrid.de/entity/Q995396 || Anton Graff, Portrait 'Detmar Basse'                        || https://database.factgrid.de/entity/Q996465 || Detmar Basse                    || http://commons.wikimedia.org/wiki/Special:FilePath/Anton_Graff_Basse_Kaufmann_aus_Frankfurt.jpg            || Unternehmer/in                  || B 71104-120: Unternehmer/in
 +
|-
 +
| https://database.factgrid.de/entity/Q995396 || Anton Graff, Portrait 'Detmar Basse'                        || https://database.factgrid.de/entity/Q996465 || Detmar Basse                    || http://commons.wikimedia.org/wiki/Special:FilePath/Anton_Graff_Basse_Kaufmann_aus_Frankfurt.jpg            || Kunstsammler/in                || A 40320-502: Kunstsammler/in
 +
|-
 +
| https://database.factgrid.de/entity/Q995397 || Anton Graff, Portrait 'Heinrich Christoph von Baudissin'    || https://database.factgrid.de/entity/Q996463 || Heinrich Christoph von Baudissin ||                                                                                                            || Gutsbesitzer/in                || B 11194-113: Gutsbesitzer/in
 +
|-
 +
| https://database.factgrid.de/entity/Q995397 || Anton Graff, Portrait 'Heinrich Christoph von Baudissin'    || https://database.factgrid.de/entity/Q996463 || Heinrich Christoph von Baudissin ||                                                                                                            || General                        ||
 +
|-
 +
| https://database.factgrid.de/entity/Q995397 || Anton Graff, Portrait 'Heinrich Christoph von Baudissin'    || https://database.factgrid.de/entity/Q996463 || Heinrich Christoph von Baudissin ||                                                                                                            || Gouverneur/in                  || B 71214-514: Gouverneur/in
 +
|-
 +
| https://database.factgrid.de/entity/Q995398 || Anton Graff, Portrait 'Heinrich Gottfried Bauer'            || https://database.factgrid.de/entity/Q947618 || Heinrich Gottfried Bauer        || http://commons.wikimedia.org/wiki/Special:FilePath/Heinrich%20Gottfried%20Bauer%2C%20by%20Anton%20Graff.jpg || Domkleriker Altes Reich        || B 83314-501: Kleriker/in
 +
|}
 +
= Tool =
 +
https://wiki.bitplan.com/index.php?title=PyLoDStorage
 +
<source lang='bash'>
 +
pip install pylodstorage
 +
</source>
 +
= endpoints.yaml =
 +
<source lang='yaml'>
 +
# SPARQL endpoints for sparqlquery tool
 +
'factgrid':
 +
  endpoint: https://database.factgrid.de/sparql/
 +
  website: https://database.factgrid.de/query/
 +
  database: factgrid
 +
  method: POST
 +
  lang: sparql
 +
  prefixes: |
 +
    PREFIX bd: <http://www.bigdata.com/rdf#>
 +
    PREFIX cc: <http://creativecommons.org/ns#>
 +
    PREFIX dct: <http://purl.org/dc/terms/>
 +
    PREFIX geo: <http://www.opengis.net/ont/geosparql#>
 +
    PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>
 +
    PREFIX owl: <http://www.w3.org/2002/07/owl#>
 +
    PREFIX p: <http://factgrid.de/prop/>
 +
    PREFIX pq: <http://factgrid.de/prop/qualifier/>
 +
    PREFIX pqn: <http://factgrid.de/prop/qualifier/value-normalized/>
 +
    PREFIX pqv: <http://factgrid.de/prop/qualifier/value/>
 +
    PREFIX pr: <http://factgrid.de/prop/reference/>
 +
    PREFIX prn: <http://factgrid.de/prop/reference/value-normalized/>
 +
    PREFIX prov: <http://www.w3.org/ns/prov#>
 +
    PREFIX prv: <http://factgrid.de/prop/reference/value/>
 +
    PREFIX ps: <http://factgrid.de/prop/statement/>
 +
    PREFIX psn: <http://factgrid.de/prop/statement/value-normalized/>
 +
    PREFIX psv: <http://factgrid.de/prop/statement/value/>
 +
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
 +
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
 +
    PREFIX schema: <http://schema.org/>
 +
    PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
 +
    PREFIX wd: <http://factgrid.de/entity/>
 +
    PREFIX wdata: <http://factgrid.de/wiki/Special:EntityData/>
 +
    PREFIX wdno: <http://factgrid.de/prop/novalue/>
 +
    PREFIX wdref: <http://factgrid.de/reference/>
 +
    PREFIX wds: <http://factgrid.de/entity/statement/>
 +
    PREFIX wdt: <http://factgrid.de/prop/direct/>
 +
    PREFIX wdtn: <http://factgrid.de/prop/direct-normalized/>
 +
    PREFIX wdv: <http://factgrid.de/value/>
 +
    PREFIX wikibase: <http://wikiba.se/ontology#>
 +
    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
 
</source>
 
</source>

Latest revision as of 05:36, 20 September 2024


Queries

# Queries
# Wolfgang Fahl 2024-09-19
# Queries
# Wolfgang Fahl 2024-09-19
'IlluminatiNoImage':
  sparql: |
    # Query for items related to Illuminati without an associated image
    # 2024-09-19 Claude
    SELECT DISTINCT ?item ?itemLabel
    WHERE {
      ?item wdt:P611 wd:Q393235 .
      ?item rdfs:label ?itemLabel_de .
         SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }
     FILTER NOT EXISTS { ?item wdt:P705 [] }.
    }
'AntonGraffPortraitsWithImages':
  param_list:
    - name: limit
      type: int
      default_value: 15
  sparql: |
    # Query for portraits by Anton Graff with optional image content and Wikimedia Commons links
    # 2024-09-19
    SELECT ?Portrait ?PortraitLabel ?depicting ?depictingLabel ?Wikimedia_Commons_Item_image ?careerLabel ?OhdabLabel WHERE {
      SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }
      ?Portrait wdt:P121 wd:Q11225.
      ?Portrait wdt:P611 wd:Q393235.
      OPTIONAL { ?Portrait wdt:P705 ?depicting.
       OPTIONAL { ?depicting wdt:P165 ?career.
        OPTIONAL { ?career wdt:P1007 ?Ohdab . }
                }
               }
      OPTIONAL { ?Portrait wdt:P189 ?Wikimedia_Commons_Item_image. }
    }
    ORDER BY ?Portrait
    LIMIT 15
'Occupation Statistics':
  sparql: |
    # Query for general occupation statistics in FactGrid
    # 2024-09-19
    SELECT ?career ?careerLabel (COUNT(DISTINCT ?person) AS ?count)
    WHERE {
      ?person wdt:P165 ?career.
      SERVICE wikibase:label { bd:serviceParam wikibase:language "de,en". }
    }
    GROUP BY ?career ?careerLabel
    ORDER BY DESC(?count)
    LIMIT {{limit}}
sparqlquery -d -qp factgrid.yaml -qn AntonGraffPortraitsWithImages -en factgrid -f mediawiki

named query AntonGraffPortraitsWithImages

sparql

# Query for portraits by Anton Graff with optional image content and Wikimedia Commons links
# 2024-09-19
SELECT ?Portrait ?PortraitLabel ?depicting ?depictingLabel ?Wikimedia_Commons_Item_image ?careerLabel ?OhdabLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "de". }
  ?Portrait wdt:P121 wd:Q11225.
  ?Portrait wdt:P611 wd:Q393235.
  OPTIONAL { ?Portrait wdt:P705 ?depicting.
   OPTIONAL { ?depicting wdt:P165 ?career.
    OPTIONAL { ?career wdt:P1007 ?Ohdab . }
            }
           }
  OPTIONAL { ?Portrait wdt:P189 ?Wikimedia_Commons_Item_image. }
}
ORDER BY ?Portrait
LIMIT 15

try it!

result

Portrait PortraitLabel depicting depictingLabel Wikimedia_Commons_Item_image careerLabel OhdabLabel
https://database.factgrid.de/entity/Q995392 Anton Graff, Portrait 'Johann Christoph Adelung' https://database.factgrid.de/entity/Q140786 Johann Christoph Adelung Johann%20Christoph%20Adelung.jpg Bibliothekar/in B 73324-107: Bibliothekar/in
https://database.factgrid.de/entity/Q995392 Anton Graff, Portrait 'Johann Christoph Adelung' https://database.factgrid.de/entity/Q140786 Johann Christoph Adelung Johann%20Christoph%20Adelung.jpg Lexikograf/in B 91184-117: Lexikograf/in
https://database.factgrid.de/entity/Q995393 Anton Graff, Portrait 'Philipp Karl von Alvensleben' https://database.factgrid.de/entity/Q249786 Philipp von Alvensleben Philipp%20Karl%20von%20Alvensleben.jpg Hofmarschall B 64194-502: Marschall/in (Hofmarschall/in)
https://database.factgrid.de/entity/Q995394 Anton Graff, Portrait 'Anton von Sachsen' https://database.factgrid.de/entity/Q234232 Anton, König von Sachsen König/in B 75394-502: König/in - Adel
https://database.factgrid.de/entity/Q995395 Anton Graff, Portrait 'Heinrich Friedrich Innocentius Apel' https://database.factgrid.de/entity/Q996462 Heinrich Friedrich Innocenz Apel H.%20F.%20I.%20Apel.jpg Bürgermeister/in B 71214-101: Bürgermeister/in
https://database.factgrid.de/entity/Q995395 Anton Graff, Portrait 'Heinrich Friedrich Innocentius Apel' https://database.factgrid.de/entity/Q996462 Heinrich Friedrich Innocenz Apel H.%20F.%20I.%20Apel.jpg Hof- und Justizrat B 73184-503: Justizrat/-rätin - herrschaftliche/r
https://database.factgrid.de/entity/Q995395 Anton Graff, Portrait 'Heinrich Friedrich Innocentius Apel' https://database.factgrid.de/entity/Q996462 Heinrich Friedrich Innocenz Apel H.%20F.%20I.%20Apel.jpg Stadtrichter/in, Ratsrichter/in B 73154-505: Stadtrichter/in, Ratsrichter/in
https://database.factgrid.de/entity/Q995395 Anton Graff, Portrait 'Heinrich Friedrich Innocentius Apel' https://database.factgrid.de/entity/Q996462 Heinrich Friedrich Innocenz Apel H.%20F.%20I.%20Apel.jpg Baumeister B 31193-107: Baumeister/in
https://database.factgrid.de/entity/Q995396 Anton Graff, Portrait 'Detmar Basse' https://database.factgrid.de/entity/Q996465 Detmar Basse Anton_Graff_Basse_Kaufmann_aus_Frankfurt.jpg Diplomat/in B 73294-523: Diplomat/in
https://database.factgrid.de/entity/Q995396 Anton Graff, Portrait 'Detmar Basse' https://database.factgrid.de/entity/Q996465 Detmar Basse Anton_Graff_Basse_Kaufmann_aus_Frankfurt.jpg Unternehmer/in B 71104-120: Unternehmer/in
https://database.factgrid.de/entity/Q995396 Anton Graff, Portrait 'Detmar Basse' https://database.factgrid.de/entity/Q996465 Detmar Basse Anton_Graff_Basse_Kaufmann_aus_Frankfurt.jpg Kunstsammler/in A 40320-502: Kunstsammler/in
https://database.factgrid.de/entity/Q995397 Anton Graff, Portrait 'Heinrich Christoph von Baudissin' https://database.factgrid.de/entity/Q996463 Heinrich Christoph von Baudissin Gutsbesitzer/in B 11194-113: Gutsbesitzer/in
https://database.factgrid.de/entity/Q995397 Anton Graff, Portrait 'Heinrich Christoph von Baudissin' https://database.factgrid.de/entity/Q996463 Heinrich Christoph von Baudissin General
https://database.factgrid.de/entity/Q995397 Anton Graff, Portrait 'Heinrich Christoph von Baudissin' https://database.factgrid.de/entity/Q996463 Heinrich Christoph von Baudissin Gouverneur/in B 71214-514: Gouverneur/in
https://database.factgrid.de/entity/Q995398 Anton Graff, Portrait 'Heinrich Gottfried Bauer' https://database.factgrid.de/entity/Q947618 Heinrich Gottfried Bauer Heinrich%20Gottfried%20Bauer%2C%20by%20Anton%20Graff.jpg Domkleriker Altes Reich B 83314-501: Kleriker/in

Tool

https://wiki.bitplan.com/index.php?title=PyLoDStorage

pip install pylodstorage

endpoints.yaml

# SPARQL endpoints for sparqlquery tool
'factgrid':
  endpoint: https://database.factgrid.de/sparql/
  website: https://database.factgrid.de/query/
  database: factgrid
  method: POST
  lang: sparql
  prefixes: |
    PREFIX bd: <http://www.bigdata.com/rdf#>
    PREFIX cc: <http://creativecommons.org/ns#>
    PREFIX dct: <http://purl.org/dc/terms/>
    PREFIX geo: <http://www.opengis.net/ont/geosparql#>
    PREFIX ontolex: <http://www.w3.org/ns/lemon/ontolex#>
    PREFIX owl: <http://www.w3.org/2002/07/owl#>
    PREFIX p: <http://factgrid.de/prop/>
    PREFIX pq: <http://factgrid.de/prop/qualifier/>
    PREFIX pqn: <http://factgrid.de/prop/qualifier/value-normalized/>
    PREFIX pqv: <http://factgrid.de/prop/qualifier/value/>
    PREFIX pr: <http://factgrid.de/prop/reference/>
    PREFIX prn: <http://factgrid.de/prop/reference/value-normalized/>
    PREFIX prov: <http://www.w3.org/ns/prov#>
    PREFIX prv: <http://factgrid.de/prop/reference/value/>
    PREFIX ps: <http://factgrid.de/prop/statement/>
    PREFIX psn: <http://factgrid.de/prop/statement/value-normalized/>
    PREFIX psv: <http://factgrid.de/prop/statement/value/>
    PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
    PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
    PREFIX schema: <http://schema.org/>
    PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
    PREFIX wd: <http://factgrid.de/entity/>
    PREFIX wdata: <http://factgrid.de/wiki/Special:EntityData/>
    PREFIX wdno: <http://factgrid.de/prop/novalue/>
    PREFIX wdref: <http://factgrid.de/reference/>
    PREFIX wds: <http://factgrid.de/entity/statement/>
    PREFIX wdt: <http://factgrid.de/prop/direct/>
    PREFIX wdtn: <http://factgrid.de/prop/direct-normalized/>
    PREFIX wdv: <http://factgrid.de/value/>
    PREFIX wikibase: <http://wikiba.se/ontology#>
    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>