User:Daniel/Queries/Graph profiling: Difference between revisions

From MaRDI portal
 
(4 intermediate revisions by the same user not shown)
Line 40: Line 40:


=== Number of types of entities in the graph ===
=== Number of types of entities in the graph ===
''This requires knowing what the graph's local equivalent of "instance of" is.'
''This requires knowing what the graph's local equivalent of "instance of" or "type" is.'


==== EU knowledge graph ====
==== EU knowledge graph ====
Line 51: Line 51:


==== DBLP KG ====
==== DBLP KG ====
* [https://sparql.dblp.org/?query=SELECT+%28count%28DISTINCT+%3Ftype+%29+as+%3Fcount%29+WHERE+%7B%0A++%3Fs%09%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23type%3E+%3Ftype+%0A%7D%0A query link]


* https://sparql.dblp.org/?query=SELECT+DISTINCT+%3Ftype+WHERE+%7B%0A%3Fs%09%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23type%3E+%3Ftype+%0A%7D%0AORDER+BY+ASC%28%3Ftype%29
<pre>
SELECT (count(DISTINCT ?type ) as ?count) WHERE {
  ?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type
}
</pre>


=== Types of entities in the graph ===
=== Types of entities in the graph ===


==== EU knowledge graph ====
<pre>
<pre>
SELECT DISTINCT ?type WHERE {
SELECT DISTINCT ?type WHERE {
   ?s wdt:P35 ?type .  
   ?s wdt:P35 ?type .  
}
}
</pre>
==== DBLP KG ====
* [https://sparql.dblp.org/?query=SELECT+DISTINCT+%3Ftype+WHERE+%7B%0A%3Fs%09%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23type%3E+%3Ftype+%0A%7D%0AORDER+BY+ASC%28%3Ftype%29 query link]
<pre>
SELECT DISTINCT ?type WHERE {
?s <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type
}
ORDER BY ASC(?type)
</pre>
</pre>


Line 71: Line 87:


=== Languages used in the graph ===
=== Languages used in the graph ===
=== Describe an example entity ===
* [https://query.portal.mardi4nfdi.de/#DESCRIBE%20wd%3AQ560634 MaRDI]
* [https://sparql.dblp.org/?query=SELECT+%3Fs+%3Fp+%3Fo+WHERE+%7B+BIND%28%3Chttps%3A%2F%2Fdblp.org%2Frec%2Fjournals%2Fnar%2FFinnBCCEEHHHMSTP14%3E+AS+%3Fs%29+%3Fs+%3Fp+%3Fo+%7D DBLP] (QLever workaround)


== Queries for Wikibase instances ==
== Queries for Wikibase instances ==

Latest revision as of 06:47, 13 November 2024

About

This page assists in the collection and curation of queries that

  • can be used with no or minimal modification on multiple graphs
  • provide insights into the graph structure

Generic queries

Number of triples in the graph

SELECT (COUNT(*) AS ?count) WHERE {
  ?s ?p ?o
}
Try it!

Number of distinct entities in the graph

Examples of distinct relationships in the graph

SELECT DISTINCT ?p WHERE {
 ?s ?p ?o .
}
LIMIT 100
Try it!
  • This currently fails (due to memory issues) for the DBLP SPARQL endpoint but

Number of distinct relationships in the graph

SELECT (COUNT(DISTINCT ?p) AS ?count) WHERE {
  ?s ?p ?o
}
Try it!

Number of types of entities in the graph

This requires knowing what the graph's local equivalent of "instance of" or "type" is.'

EU knowledge graph

For instance, in the EU knowledge graph, this would be P35, leading to the following query.

SELECT (count(DISTINCT ?type ) as ?count) WHERE {
  ?s <https://linkedopendata.eu/entity/P35> ?type . 
}

DBLP KG

SELECT (count(DISTINCT ?type ) as ?count) WHERE {
  ?s	<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type 
}

Types of entities in the graph

EU knowledge graph

SELECT DISTINCT ?type WHERE {
  ?s wdt:P35 ?type . 
}

DBLP KG

SELECT DISTINCT ?type WHERE {
?s	<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?type 
}
ORDER BY ASC(?type)

External entities equivalent to entities in the graph

External entities equivalent to relationships in the graph

Entities with the largest number of triples

Entities with the lowest number of triples

Languages used in the graph

Describe an example entity

Queries for Wikibase instances

# Properties by frequency in a random sample 
SELECT DISTINCT ?property ?propertyLabel (COUNT(*) AS ?count) WHERE {
  SERVICE bd:sample { ?item ?p [ ] . bd:serviceParam bd:sample.limit 1000 }
  
  ?property a wikibase:Property;
              wikibase:claim ?p.
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
GROUP BY ?property ?propertyLabel
ORDER BY DESC(?count)
Try it!

Queries for a specific set of KGs

  • Relative coverage of zbMATH authors in MaRDI vs. Wikidata

See also