Jump to content

DebugQueries: Difference between revisions

Leonie (talk | contribs)
Added access to backlink query
Leonie (talk | contribs)
added queries: Quizzes, Resources, Instance-less Resources
Line 4: Line 4:


= Useful Queries =
= Useful Queries =
A List of accessible queries, that are usefull to understand the structure of the graph and identify problems, such as missing links.
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 ==
== Backlinks ==
'''A query that finds all backlinks to a specific item.'''
'''A query that finds all backlinks to a specific item.'''
Line 40: Line 40:
}
}
}}
}}
----


=== Unlinked Resources ===
=== Unlinked Resources ===
Line 62: Line 60:
}}
}}


----
=== Instance-less Resources ===
'''Returns all Resources that have no Property [[Property:P3|instance of]].'''
{{#widget:SPARQLquery|code=
#All Resources that don't have a Property: instance of
#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" }
}
 
}}


== No Subclass ==
== No Subclass ==
Line 79: Line 92:
}
}
}}
}}
----


== No Dependencies ==
== No Dependencies ==
Line 101: Line 112:
}}
}}


----
== Orphans ==
== Orphans ==
''' Returns all items, that don't link to any other items and are not linked to in return.'''
''' Returns all items, that don't link to any other items and are not linked to in return.'''
Line 118: Line 128:
   MINUS {?source wdt:P1 ?dependency}. # Remove all items that have a dependency
   MINUS {?source wdt:P1 ?dependency}. # Remove all items that have a dependency
    
    
  service wikibase:label { bd:serviceParam wikibase:language "en" }
}
}}
----
= Access to Item =
Queries that find items with specific proterties for an easier overview.
== Quizzes ==
'''Returns all Items that are Quizzes.'''
{{#widget:SPARQLquery|code=
#All Items that are a Quiz
#defaultView:Table
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wd: <https://graphit.ur.de/entity/>
SELECT ?source ?sourceLabel ?url
WHERE {
 
  # All Items that are an instance of Property Quiz
  ?source wdt:P3 wd:Q162.
  ?source wdt:P20 ?url.
 
  service wikibase:label { bd:serviceParam wikibase:language "en" }
}
}}
== Resources ==
'''Returns all Resources.'''
{{#widget:SPARQLquery|code=
#defaultView:Table
PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wd: <https://graphit.ur.de/entity/>
SELECT DISTINCT ?resource ?resourceLabel
WHERE {
 
  ?source wdt:P21 ?resource.
   service wikibase:label { bd:serviceParam wikibase:language "en" }
   service wikibase:label { bd:serviceParam wikibase:language "en" }
}
}
}}
}}

Revision as of 09:28, 21 August 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.

A query that finds all backlinks to a specific item.

{{#if: GLSL (Q61) | Items used: GLSL (Q61) | }}

{{#if: depends on (P1) | Properties used: depends on (P1) | }}

{{#if:|
{{ safesubst:p{{ safesubst:#ifeq:|eq|1|2}}|{{ safesubst:p{{ safesubst:#ifeq:|
PREFIX p: <https://graphit.ur.de/prop/>|1|2}}||}}|{{ safesubst:p{{ safesubst:#if:|1|2}}|
PREFIX p: <https://graphit.ur.de/prop/>|}}}}{{ safesubst:p{{ safesubst:#ifeq:|eq|1|2}}|{{ safesubst:p{{ safesubst:#ifeq:|
PREFIX q: <https://graphit.ur.de/prop/qualifier/>|1|2}}||}}|{{ safesubst:p{{ safesubst:#if:|1|2}}|
PREFIX q: <https://graphit.ur.de/prop/qualifier/>|}}}}{{ safesubst:p{{ safesubst:#ifeq:|eq|1|2}}|{{ safesubst:p{{ safesubst:#ifeq:|
PREFIX v: <https://graphit.ur.de/prop/statement/>|1|2}}||}}|{{ safesubst:p{{ safesubst:#if:|1|2}}|
PREFIX v: <https://graphit.ur.de/prop/statement/>|}}}}{{ safesubst:p{{ safesubst:#ifeq:|eq|1|2}}|{{ safesubst:p{{ safesubst:#ifeq:|
|1|2}}||}}|{{ safesubst:p{{ safesubst:#if:|1|2}}|
|}}}}
}}PREFIX wdt: <https://graphit.ur.de/prop/direct/>
PREFIX wd: <https://graphit.ur.de/entity/>
SELECT DISTINCT ?source ?sourceLabel
WHERE {
  ?source wdt:P1 wd:Q61.
  service wikibase:label { bd:serviceParam wikibase:language "en". }
}

Try it!



Missing Properties

Resources

No Resources

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

{{#widget:SPARQLquery|code=

  1. All Items with no linked resources
  2. defaultView:Table

PREFIX wdt: <https://graphit.ur.de/prop/direct/> PREFIX wd: <https://graphit.ur.de/entity/> SELECT DISTINCT ?source ?sourceLabel ?resource ?resourceLabel WHERE {

 # Select all items
 ?source wdt:P1 ?dependency.
 ?source wdt:P2 ?class.
 MINUS {?source wdt:P21 ?resource.}
 
 service wikibase:label { bd:serviceParam wikibase:language "en". }

} }}

Unlinked Resources

Returns all resources, that have not been linked to any item yet. {{#widget:SPARQLquery|code=

  1. Resources that aren't linked
  2. defaultView:Table

PREFIX wdt: <https://graphit.ur.de/prop/direct/> PREFIX wd: <https://graphit.ur.de/entity/> SELECT DISTINCT ?source ?sourceLabel ?resource ?resourceLabel WHERE {

 # select all resources (they have urls)
 ?source wdt:P20 ?url. # 151
 MINUS { 
   ?dependency wdt:P21 ?source
 }
 
 service wikibase:label { bd:serviceParam wikibase:language "en". }

} }}

Instance-less Resources

Returns all Resources that have no Property instance of. {{#widget:SPARQLquery|code=

  1. All Resources that don't have a Property: instance of
  2. 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" }

}

}}

No Subclass

Returns all Items, that don't have a property subclass. {{#widget:SPARQLquery|code=

  1. All Items no subclass
  2. 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" }

} }}

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 a source or that they are orphaned. {{#widget:SPARQLquery|code=

  1. All items that don't linkt to another item (no dependency)
  2. 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" }

} }}

Orphans

Returns all items, that don't link to any other items and are not linked to in return.

NOTE: Not sure if this works. {{#widget:SPARQLquery|code=

  1. All items that don't linkt to another item (no dependency)
  2. 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. # get all items that have a subclass.
 MINUS {?dependency wdt:P1 ?source}. # Remove all items that have the ?source as a dependency
 MINUS {?source wdt:P1 ?dependency}. # Remove all items that have a dependency
 
 service wikibase:label { bd:serviceParam wikibase:language "en" }

} }}


Access to Item

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

Quizzes

Returns all Items that are Quizzes. {{#widget:SPARQLquery|code=

  1. All Items that are a Quiz
  2. defaultView:Table

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

 # All Items that are an instance of Property Quiz 
 ?source wdt:P3 wd:Q162.
 ?source wdt:P20 ?url.
 
 service wikibase:label { bd:serviceParam wikibase:language "en" }

} }}

Resources

Returns all Resources. {{#widget:SPARQLquery|code=

  1. defaultView:Table

PREFIX wdt: <https://graphit.ur.de/prop/direct/> PREFIX wd: <https://graphit.ur.de/entity/> SELECT DISTINCT ?resource ?resourceLabel WHERE {

 ?source wdt:P21 ?resource.
 service wikibase:label { bd:serviceParam wikibase:language "en" }

} }}