Difference between revisions of "Truly Tabular RDF/Info"

From BITPlan Wiki
Jump to navigation Jump to search
Line 43: Line 43:
 
== ?f ==
 
== ?f ==
 
== ?ex ==
 
== ?ex ==
 +
try it! link to examples for "non-tabular" entries. E.g. for the property "manufacturer" of the class "beer" the query
 +
<source lang='SPARQL'>
 +
# This query was generated by Truly Tabular
 +
# Count all Q44:beer items
 +
# with the given manufacturer(P176) https://www.wikidata.org/wiki/Property:P176
 +
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 wd: <http://www.wikidata.org/entity/>
 +
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
 +
PREFIX wikibase: <http://wikiba.se/ontology#>
 +
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
 +
 +
SELECT ?item ?itemLabel (COUNT (?value) AS ?count)
 +
WHERE
 +
{
 +
  # instance of beer
 +
  ?item wdt:P31 wd:Q44.
 +
  ?item rdfs:label ?itemLabel.
 +
  FILTER (LANG(?itemLabel) = "en").
 +
  # manufacturer
 +
  ?item wdt:P176 ?value.
 +
} GROUP BY ?item ?itemLabel
 +
 +
HAVING (COUNT (?value) > 1)
 +
ORDER BY DESC(?count) try it
 +
</source>
 +
[https://query.wikidata.org/#%23%20This%20query%20was%20generated%20by%20Truly%20Tabular%0A%23%20Count%20all%20Q44%3Abeer%20items%0A%23%20with%20the%20given%20manufacturer%28P176%29%20https%3A%2F%2Fwww.wikidata.org%2Fwiki%2FProperty%3AP176%20%0APREFIX%20rdf%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E%0APREFIX%20rdfs%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F2000%2F01%2Frdf-schema%23%3E%0APREFIX%20schema%3A%20%3Chttp%3A%2F%2Fschema.org%2F%3E%0APREFIX%20wd%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fentity%2F%3E%0APREFIX%20wdt%3A%20%3Chttp%3A%2F%2Fwww.wikidata.org%2Fprop%2Fdirect%2F%3E%0APREFIX%20wikibase%3A%20%3Chttp%3A%2F%2Fwikiba.se%2Fontology%23%3E%0APREFIX%20xsd%3A%20%3Chttp%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23%3E%0A%0ASELECT%20%3Fitem%20%3FitemLabel%20%28COUNT%20%28%3Fvalue%29%20AS%20%3Fcount%29%0AWHERE%0A%7B%0A%20%20%23%20instance%20of%20beer%0A%20%20%3Fitem%20wdt%3AP31%20wd%3AQ44.%0A%20%20%3Fitem%20rdfs%3Alabel%20%3FitemLabel.%0A%20%20FILTER%20%28LANG%28%3FitemLabel%29%20%3D%20%22en%22%29.%0A%20%20%23%20manufacturer%0A%20%20%3Fitem%20wdt%3AP176%20%3Fvalue.%0A%7D%20GROUP%20BY%20%3Fitem%20%3FitemLabel%0A%0AHAVING%20%28COUNT%20%28%3Fvalue%29%20%3E%201%29%0AORDER%20BY%20DESC%28%3Fcount%29 try it!]
 +
will be generated which reveals that there are two kinds of beers that have two manufacturers:
 +
[http://www.wikidata.org/entity/Q15980473 Žatecký Gus] which is manufactured by [https://www.wikidata.org/wiki/Q4035888 Carlsberg Ukraine] and [https://www.wikidata.org/wiki/Q805734 Baltika Breweries]
 +
and [http://www.wikidata.org/entity/Q789278 Balatoni Világos] which is manufactured by
 +
 
== ✔ ==
 
== ✔ ==
  

Revision as of 16:19, 2 August 2022

Property columns

#

rank of the property in order of the percentage of instances where at lest one values is available for the property

%

The percentage of instances where at least one value is available for the property

pareto

The Pareto level according to the Pareto principle 80:20 (1 out of 5) as a logarithmic scale to the basis 5..

Pareto levels
level ratio 1 out of
1 80:20 5
2 96:4 25
3 99.2:0.8 125
4 99.84:0.16 625
5 99.97:0.03 3125
6 99.994:0.006 15625
7 99.9987:0.0013 78125
8 99.99974:0.00026 390625
9 99.99995:0.00005 1953125

property

A Wikidata Property e.g. P31/instance of

propertyId

The property Identifier for a Property e.g. P31 for P31/instance of

Statistics

1

maxf

nt

nt%

?f

?ex

try it! link to examples for "non-tabular" entries. E.g. for the property "manufacturer" of the class "beer" the query

# This query was generated by Truly Tabular
# Count all Q44:beer items
# with the given manufacturer(P176) https://www.wikidata.org/wiki/Property:P176 
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 wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT ?item ?itemLabel (COUNT (?value) AS ?count)
WHERE
{
  # instance of beer
  ?item wdt:P31 wd:Q44.
  ?item rdfs:label ?itemLabel.
  FILTER (LANG(?itemLabel) = "en").
  # manufacturer
  ?item wdt:P176 ?value.
} GROUP BY ?item ?itemLabel

HAVING (COUNT (?value) > 1)
ORDER BY DESC(?count) try it

try it! will be generated which reveals that there are two kinds of beers that have two manufacturers: Žatecký Gus which is manufactured by Carlsberg Ukraine and Baltika Breweries and Balatoni Világos which is manufactured by

Aggregates

count

apply SPARQL

COUNT()

aggregate

min

apply SPARQL

MIN()

aggregate

max

apply SPARQL

MAX()

aggregate

avg

apply SPARQL

AVG()

aggregate

sample

apply SPARQL

SAMPLE()

aggregate

list

apply

GROUP_CONCAT()

aggregate to avoid multiple solutions for the same instance

ignore

Ignore SPARQL solutions that have multiple values for the given property by using a

HAVING COUNT<=1

aggregate condition in the generated query

label

Show the label of the property result in the generated SPARQL query.

select

If a property is selected it will be included in the generated SPARQL query