DebugQueries: Difference between revisions

(→‎Access to Items: update; added: Not in Sessions)
Line 78: Line 78:
=== Instance-less Resources ===
=== Instance-less Resources ===
'''Returns all Resources that have no Property [[Property:P3|instance of]].'''
'''Returns all Resources that have no Property [[Property:P3|instance of]].'''
{{#widget:SPARQLquery|code=
{{SPARQL2|query=
#All Resources that don't have a Property: instance of
#defaultView:Table
#defaultView:Table
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
Line 85: Line 84:
SELECT ?resource ?resourceLabel ?instanceOf
SELECT ?resource ?resourceLabel ?instanceOf
WHERE {
WHERE {
 
   ?source wdt:P21 ?resource.
   ?source wdt:P21 ?resource.
   MINUS {?resource wdt:P3 ?instanceOf}
   MINUS {?resource wdt:P3 ?instanceOf}
Line 95: Line 93:
== No Subclass ==
== No Subclass ==
'''Returns all Items, that don't have a property [[Property:P2|subclass]].'''
'''Returns all Items, that don't have a property [[Property:P2|subclass]].'''
{{#widget:SPARQLquery|code=
{{SPARQL2|query=
#All Items no subclass
#defaultView:Table
#defaultView:Table
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
Line 113: Line 110:


These items don't have a property [[Property:P1|depends on]]. This could mean, that they are the begining of a path.
These items don't have a property [[Property:P1|depends on]]. This could mean, that they are the begining of a path.
{{#widget:SPARQLquery|code=
{{SPARQL2|query=
# All items that don't linkt to another item (no dependency)
#defaultView:Table
#defaultView:Table
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
Line 148: Line 144:
== No Description ==
== No Description ==
'''Returns all items without a description.'''
'''Returns all items without a description.'''
{{#widget:SPARQLquery|code=
{{SPARQL2|query=
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wd: <https://graphit.ur.de/entity/>
PREFIX wd: <https://graphit.ur.de/entity/>
Line 160: Line 156:


== No Instance ==
== No Instance ==
'''Returns all items that have and their Property [[Property:P3|instance of]].''' Shows which items are not, e.g. Applications.
'''Returns all items that have no Property [[Property:P3|instance of]].''' Shows which items are not, e.g. Applications.
{{#widget:SPARQLquery|code=
{{SPARQL2|query=
#defaultView:Table
#defaultView:Table
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wdt: <https://graphit.ur.de/prop/direct/>

Revision as of 09:38, 15 September 2023

This page contains several SPARQL-Queries to help debug the graph.

Useful Queries

A List of accessible queries, that are useful to understand the structure of the graph and identify problems, such as missing links. They can be changed as needed.

Backlinks

A query that finds all backlinks to a specific item.

Items used: Polygons (Q108)


#defaultView:Graph
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wd: <https://graphit.ur.de/entity/>
select distinct ?subject ?subjectLabel ?item ?itemLabel { # ?property ?propertyLabel
  values (?item) {(wd:Q108)}
  ?subject ?predicate ?item .
  ?property wikibase:directClaim ?predicate
  service wikibase:label { bd:serviceParam wikibase:language "en" }
}

Try it!


All Items

Returns a list of all items and how they are categorized in alphabetical order. In this case categories are all items that are used to structure the graph, such as Article or Markers. This list can help spot duplicates or similiar items.



#defaultView:Table
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wd: <https://graphit.ur.de/entity/>
select distinct ?item ?itemLabel {
  ?item ?predicate ?dependency.
  ?property wikibase:directClaim ?predicate
  service wikibase:label { bd:serviceParam wikibase:language "en" }
}
order by asc(UCASE(str(?itemLabel)))

Try it!



Missing Properties

Resources

No Resources

Returns all Items, that don't have any resource that they link to.

Unlinked Resources

Returns all resources, that have not been linked to any item yet.

Instance-less Resources

Returns all Resources that have no Property instance of.


Properties used: resource (P21), instance of (P3)

#defaultView:Table
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wd: <https://graphit.ur.de/entity/>
SELECT ?resource ?resourceLabel ?instanceOf
WHERE {
  ?source wdt:P21 ?resource.
  MINUS {?resource wdt:P3 ?instanceOf}
  service wikibase:label { bd:serviceParam wikibase:language "en" }
}

Try it!


No Subclass

Returns all Items, that don't have a property subclass.


Properties used: depends on (P1), subclass of (P2)

#defaultView:Table
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wd: <https://graphit.ur.de/entity/>
SELECT DISTINCT ?source ?sourceLabel ?subclass 
WHERE {
  ?source wdt:P1 ?dependency.
  MINUS {?source wdt:P2 ?class. }
  
  service wikibase:label { bd:serviceParam wikibase:language "en" }
}

Try it!


No Dependencies

Returns all Items, that don't link any other items as dependency.

These items don't have a property depends on. This could mean, that they are the begining of a path.


Properties used: subclass of (P2), depends on (P1)

#defaultView:Table
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wd: <https://graphit.ur.de/entity/>
SELECT ?source ?sourceLabel ?dependency
WHERE {

  ?source wdt:P2 ?class.
  MINUS {?source wdt:P1 ?dependency.}
  
  service wikibase:label { bd:serviceParam wikibase:language "en" }
}

Try it!


No Links

Returns all Graph-items, that don't link to any other items and are not linked to in return. Does not return items used to structure the graph, such as Essential

No Description

Returns all items without a description.


Properties used: subclass of (P2)

PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wd: <https://graphit.ur.de/entity/>
SELECT DISTINCT ?item ?itemLabel ?itemDescription
WHERE {
  ?item wdt:P2 ?class.
  MINUS {?item schema:description ?itemDescription }
  service wikibase:label { bd:serviceParam wikibase:language "en". }
}

Try it!


No Instance

Returns all items that have no Property instance of. Shows which items are not, e.g. Applications.


Properties used: subclass of (P2), instance of (P3)

#defaultView:Table
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wd: <https://graphit.ur.de/entity/>
select distinct ?item ?itemLabel ?instance ?instanceLabel {
  
  ?item wdt:P2 ?class.
  optional { ?item wdt:P3 ?instance }
  # MINUS { ?item wdt:P3 ?instance } # Removes items with instance
  
  service wikibase:label { bd:serviceParam wikibase:language "en" }
}

Try it!



Access to Items

Queries that find items with specific proterties for an easier overview.

Quizzes

Returns all Items that are Quizzes.

Resources

Returns all Resources.


Properties used: url (P20)

#defaultView:Table
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wd: <https://graphit.ur.de/entity/>
SELECT DISTINCT ?resource ?resourceLabel ?labelLength 
WHERE {
  ?resource wdt:P20 ?url.
  ?resource rdfs:label ?resourceLabel.
  BIND (strlen(str(?resourceLabel)) AS ?labelLength)
  service wikibase:label { bd:serviceParam wikibase:language "en" }
}

Try it!


Labels

Returns the items with the longest Labels (50). Doesn't return Resources.

Here it could be useful to find shorter alias for the items, for easier viewing in a visualisation. Items used: Student (Q167)

Properties used: subclass of (P2), url (P20), instance of (P3)

#defaultView:Table
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wd: <https://graphit.ur.de/entity/>
select distinct ?item ?itemLabel ?length ?alias { # ?property ?propertyLabel
  
  # ?item wdt:P2 ?class.
  ?item rdfs:label ?itemLabel.
  MINUS {?item wdt:P20 ?url}
  MINUS {?item wdt:P3 wd:Q167} # no Students
  BIND (strlen(str(?itemLabel)) AS ?length)
  OPTIONAL {?item skos:altLabel ?alias}
  
  service wikibase:label { bd:serviceParam wikibase:language "en" }
}
ORDER BY DESC(strlen(str(?itemLabel))) LIMIT 50

Try it!


Orphans

Returns all items that have no Properties. Excludes all Property-Items, such as depends on

Categories

Returns all Categories and their sub-items. Items used: Category (Q169)

Properties used: instance of (P3), subclass of (P2)

#defaultView:Graph
#get all Items of a category
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wd: <https://graphit.ur.de/entity/>
select distinct ?item ?itemLabel ?category ?categoryLabel {
  ?category wdt:P3 wd:Q169.
  ?item wdt:P2 ?category.
  service wikibase:label { bd:serviceParam wikibase:language "en" }
}

Try it!


Sessions

Returns all Sessions, all Items that they include and the Course that includes them. Excludes all items that are resources. Items used: Quiz (Q162)

Properties used: includes (P14), url (P20), instance of (P3)

#defaultView:Graph
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wd: <https://graphit.ur.de/entity/>
select distinct ?item ?itemLabel ?session ?sessionLabel ?course ?courseLabel ?edgeLabel
where {
  
  ?session wdt:P14 ?item.
  MINUS {?item wdt:P20 ?url.}
  MINUS {?session wdt:P3 wd:Q162.}

  service wikibase:label { bd:serviceParam wikibase:language "en".}
}

Try it!


Not in Sessions

Returns all items that are not (yet) part of a Session.


Miscellaneous

Circle Dependency

Returns items that link back towards each other, creating a circle dependency.

Categories with Resources

Returns all Categories that link to resources. This could be a sign to create new items or find better item to properly link these resources to.