Difference between revisions of "Factgrid2024-09-19"

From BITPlan cr Wiki
Jump to navigation Jump to search
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
 
= 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 17: 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 32: 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>
 
<source lang='bash'>
 
<source lang='bash'>
Line 37: Line 56:
 
</source>
 
</source>
 
=== named query AntonGraffPortraitsWithImages ===
 
=== named query AntonGraffPortraitsWithImages ===
</source>
+
 
 
== sparql ==
 
== sparql ==
 
<source lang='sparql'>
 
<source lang='sparql'>

Latest revision as of 06: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#>