= SPARQL Queries for CMD2RDF == CMDM - Model == Profiles and Components - Schemas List all profiles with their id and number of instances: {{{ #!sql PREFIX cmdm: PREFIX dcterms: SELECT SAMPLE(?p) as ?profile SAMPLE(?pid) as ?pid COUNT(?i) as ?count WHERE { ?p rdfs:subClassOf cmdm:Profile. ?p dcterms:identifier ?pid. ?i a ?p. } GROUP by ?p ?pid ORDER BY DESC(?count) }}} [[http://clarin.aac.ac.at/virtuoso/sparql?default-graph-uri=&query=PREFIX+cmdm%3A+%3Chttp%3A%2F%2Fwww.clarin.eu%2Fcmd%2Fgeneral.rdf%23%3E%0D%0A%0D%0ASELECT+SAMPLE%28%3Fp%29+as++%3Fprofile+SAMPLE%28%3Fpid%29+as+%3Fpid+COUNT%28%3Fi%29+as+%3Fcount+WHERE+{+%3Fp+rdfs%3AsubClassOf+cmdm%3AProfile.+%0D%0A%3Fp+dcterms%3Aidentifier+%3Fpid.%0D%0A%3Fi+a+%3Fp.%0D%0A+}%0D%0AGROUP+by+%3Fp+%3Fpid%0D%0AORDER+BY+DESC%28%3Fcount%29&format=text%2Fhtml&timeout=0&debug=on|result in clarin.aac.ac.at-virtuoso]], [[http://clarin.aac.ac.at/virtuoso/sparql?default-graph-uri=&query=PREFIX+cmdm%3A+%3Chttp%3A%2F%2Fwww.clarin.eu%2Fcmd%2Fgeneral.rdf%23%3E%0D%0A%0D%0ASELECT+%3Fp+WHERE+{+%3Fp+rdfs%3AsubClassOf+cmdm%3AProfile+}&format=text%2Fhtml&timeout=0&debug=on|​just profiles]] List the `cmdm:contains` relation pairs, grouped by type with count: {{{ #!sql SELECT (SAMPLE(?t1) AS ?PARENT) (SAMPLE(?t2) AS ?CHILD) (COUNT(?c2) as ?COUNT) WHERE { ?c1 ?c2. ?c1 a ?t1. ?c2 a ?t2. } GROUP BY ?t1 ?t2 ORDER BY ?t1 ?t2 }}} [[http://clarin.aac.ac.at/isparql/view/?query=SELECT%20%28SAMPLE%28%3Ft1%29%20AS%20%3FPARENT%29%20%28SAMPLE%28%3Ft2%29%20AS%20%3FCHILD%29%20%28COUNT%28%3Fc2%29%20as%20%3FCOUNT%29%0AWHERE%20{%20%0A%20%20%20%3Fc1%20%3Chttp%3A%2F%2Fwww.clarin.eu%2Fcmd%2Fgeneral.rdf%23contains%3E%20%3Fc2.%0A%20%20%20%3Fc1%20a%20%3Ft1.%20%3Fc2%20a%20%3Ft2.%0A%20}%20%0AGROUP%20BY%20%3Ft1%20%3Ft2%0AORDER%20BY%20%3Ft1%20%3Ft2&endpoint=%2Fsparql&maxrows=50&timeout=&default-graph-uri=&view=1&amode=0&raw_iris=false|result]] == Inspect data categories List all used datcats, with counts: {{{ #!sql PREFIX dcr: SELECT SAMPLE(?datcat) COUNT(?e) as ?count WHERE {?e dcr:datcat ?datcat} GROUP BY ?datcat ORDER BY DESC(?count) }}} List all used datcats, with english labels and counts: {{{ #!sql PREFIX dcr: SELECT SAMPLE(?datcatid) SAMPLE(?datcatlabel) COUNT(?e) as ?count WHERE {?e dcr:datcat ?datcatid. ?datcat dcr:datcat ?datcatid. ?datcat rdfs:label ?datcatlabel. FILTER(langMatches(lang(?datcatlabel), "EN")) } GROUP BY ?datcatid ?datcatlabel ORDER BY DESC(?count) }}} [[http://clarin.aac.ac.at/virtuoso/sparql?default-graph-uri=&query=PREFIX+dcr%3A+%3Chttp%3A%2F%2Fwww.isocat.org%2Fns%2Fdcr.rdf%23%3E%0D%0A%0D%0ASELECT+SAMPLE%28%3Fdatcatid%29+SAMPLE%28%3Fdatcatlabel%29+COUNT%28%3Fe%29+as+%3Fcount%0D%0AWHERE+{%3Fe+dcr%3Adatcat+%3Fdatcatid.%0D%0A+++++++%3Fdatcat+dcr%3Adatcat+%3Fdatcatid.%0D%0A+++++++%3Fdatcat+rdfs%3Alabel+%3Fdatcatlabel.%0D%0A++FILTER%28langMatches%28lang%28%3Fdatcatlabel%29%2C+%22EN%22%29%29%0D%0A}%0D%0AGROUP+BY+%3Fdatcatid+%3Fdatcatlabel%0D%0AORDER+BY+DESC%28%3Fcount%29&format=text%2Fhtml&timeout=0&debug=on|datcat with label and counts]] List all relations from the relation registry: {{{ #!sql SELECT ?dc1 ?reltype ?dc2 WHERE { { GRAPH {?dc1 ?reltype ?dc2 } } UNION { GRAPH {?dc1 ?reltype ?dc2 } } } }}} List values in fields for given data category (`DC-2544` resourceTitle): {{{ #!sql PREFIX dcr: SELECT ?v as ?resourcetitle WHERE {?cmdelem dcr:datcat "http://www.isocat.org/datcat/DC-2544". ?instelem a ?cmdelem. ?instelem ?p ?v. FILTER isLiteral(?v) } ORDER BY ?v }}} Datcats with the number of elements they are references by and the number of corresponding instances: {{{ #!sql PREFIX dcr: SELECT SAMPLE(?datcatid) COUNT(distinct ?cmdelem) as ?count COUNT(?instelem) as ?count_instances WHERE {?cmdelem dcr:datcat ?datcatid. ?instelem a ?cmdelem. } GROUP BY ?datcatid ORDER BY DESC(?count_instances) }}} == Inspect instance data === Language List distinct used `LanguageNames`: {{{ #!sql PREFIX cmd-lang: SELECT SAMPLE(?v) COUNT(?v) WHERE { [] cmd-lang:Language.hasLanguageNameElementValue ?v. } GROUP BY ?v }}} [[http://clarin.aac.ac.at/isparql/view/?query=PREFIX%20cmd-lang%3A%20%3Chttp%3A%2F%2Fcatalog.clarin.eu%2Fds%2FComponentRegistry%2Frest%2Fregistry%2Fcomponents%2Fclarin.eu%3Acr1%3Ac_1271859438111%2Frdf%23%3E%0A%0ASELECT%20SAMPLE%28%3Fv%29%20COUNT%28%3Fv%29%0AWHERE%20{%20%0A%20%20%20[]%20cmd-lang%3ALanguage.hasLanguageNameElementValue%20%3Fv.%0A%20}%20%0AGROUP%20BY%20%3Fv&endpoint=%2Fsparql&maxrows=50&timeout=&default-graph-uri=&view=1&amode=0&raw_iris=false|result]] List distinct LangNames and corresponding LangCodes order by frequency: {{{ PREFIX cmdm: PREFIX cmd-lang: PREFIX cmd-iso639: SELECT SAMPLE(?langnamevalue) as ?langname SAMPLE(?iso639codevalue) as ?langcode COUNT(?langnamevalue) as ?count WHERE { ?langname cmd-lang:Language.hasLanguageNameElementValue ?langnamevalue. ?lang cmdm:contains ?langname. ?lang cmdm:contains ?iso639. ?iso639 cmdm:contains ?iso639code. ?iso639code a cmd-iso639:ISO639.iso-639-3-code. ?iso639code cmd-iso639:ISO639.hasiso-639-3-codeElementValue ?iso639codevalue. } GROUP BY ?langnamevalue ?iso639codevalue ORDER BY DESC(?count) }}} [[http://clarin.aac.ac.at/isparql/view/?query=PREFIX%20cmdm%3A%20%3Chttp%3A%2F%2Fwww.clarin.eu%2Fcmd%2Fgeneral.rdf%23%3E%0APREFIX%20cmd-lang%3A%20%3Chttp%3A%2F%2Fcatalog.clarin.eu%2Fds%2FComponentRegistry%2Frest%2Fregistry%2Fcomponents%2Fclarin.eu%3Acr1%3Ac_1271859438111%2Frdf%23%3E%0APREFIX%20cmd-iso639%3A%20%3Chttp%3A%2F%2Fcatalog.clarin.eu%2Fds%2FComponentRegistry%2Frest%2Fregistry%2Fcomponents%2Fclarin.eu%3Acr1%3Ac_1271859438110%2Frdf%23%3E%0A%0ASELECT%20SAMPLE(%3Flangnamevalue)%20as%20%3Flangname%20SAMPLE(%3Fiso639codevalue)%20as%20%3Flangcode%20COUNT(%3Flangnamevalue)%20as%20%3Fcount%0AWHERE%20%7B%20%0A%20%20%20%3Flangname%20cmd-lang%3ALanguage.hasLanguageNameElementValue%20%3Flangnamevalue.%0A%20%20%20%3Flang%20cmdm%3Acontains%20%3Flangname.%0A%20%20%20%3Flang%20cmdm%3Acontains%20%3Fiso639.%0A%20%20%20%3Fiso639%20cmdm%3Acontains%20%3Fiso639code.%0A%20%20%20%3Fiso639code%20a%20cmd-iso639%3AISO639.iso-639-3-code.%0A%20%20%20%3Fiso639code%20cmd-iso639%3AISO639.hasiso-639-3-codeElementValue%20%3Fiso639codevalue.%0A%20%7D%20%0AGROUP%20BY%20%3Flangnamevalue%20%20%3Fiso639codevalue%0AORDER%20BY%20DESC(%3Fcount)&endpoint=%2Fsparql&maxrows=50&timeout=&default-graph-uri=&view=1&amode=0&raw_iris=false|result]] === Search by !DatCat Search in description fields for string `syntax` or `parse`, get the field value and the resource-identifier: {{{ #!sql PREFIX dcr: SELECT ?g as ?resGraph ?v as ?resourcetitle WHERE { GRAPH ?g {?cmdelem dcr:datcat "http://www.isocat.org/datcat/DC-2520".} ?instelem a ?cmdelem. ?instelem ?p ?v. FILTER isLiteral(?v). FILTER REGEX(?v, "(syntax|parse)", "i") } }}} [[http://clarin.aac.ac.at/virtuoso/sparql?default-graph-uri=&query=PREFIX+dcr%3A+%3Chttp%3A%2F%2Fwww.isocat.org%2Fns%2Fdcr.rdf%23%3E%0D%0A%0D%0ASELECT+%3Fg+as+%3FresGraph+%3Fv+as+%3Fresourcetitle%0D%0AWHERE+{+GRAPH+%3Fg+{%3Fcmdelem+dcr%3Adatcat+%22http%3A%2F%2Fwww.isocat.org%2Fdatcat%2FDC-2520%22.}%0D%0A+++++++%3Finstelem+a+%3Fcmdelem.%0D%0A+++++++%3Finstelem+%3Fp+%3Fv.%0D%0A%0D%0AFILTER+isLiteral%28%3Fv%29.%0D%0AFILTER+REGEX%28%3Fv%2C+%22%28syntax%7Cparse%29%22%2C+%22i%22%29%0D%0A}&format=text%2Fhtml&timeout=0&debug=on| syntax or parse in description ]] (by datcat: [[http://isocat.org/datcat/2520|Description]] `DC-2520`) === Traverse `cmdm:contains` List all elements starting from given root component, show the element type and the value: {{{ #!sql PREFIX oa: PREFIX cmdm: SELECT ?elemtype ?value WHERE {?rootcomponent a . ?rootcomponent cmdm:contains* ?comp. ?comp cmdm:contains ?elem. ?elem a ?elemtype. ?elem ?haselemvalue ?value. ?elemtype rdfs:subClassOf cmdm:Element. FILTER( isLiteral(?value)) FILTER( regex(?value,'.')) } }}} [[http://clarin.aac.ac.at/virtuoso/sparql?default-graph-uri=&query=PREFIX+oa%3A+%3Chttp%3A%2F%2Fwww.w3.org%2Fns%2Foa%23%3E%0D%0APREFIX+cmdm%3A+%3Chttp%3A%2F%2Fwww.clarin.eu%2Fcmd%2Fgeneral.rdf%23%3E%0D%0A%0D%0A%0D%0Aselect+%3Felemtype+%3Fvalue+where+{%3Frootcomponent+a+%3Chttp%3A%2F%2Fcatalog.clarin.eu%2Fds%2FComponentRegistry%2Frest%2Fregistry%2Fprofiles%2Fclarin.eu%3Acr1%3Ap_1290431694579%2Frdf%23LexicalResourceProfile%3E.%0D%0A+%3Frootcomponent+cmdm%3Acontains*+%3Fcomp.+%0D%0A+%3Fcomp+cmdm%3Acontains+%3Felem.%0D%0A+%3Felem+a+%3Felemtype.%0D%0A+%3Felem+%3Fhaselemvalue+%3Fvalue.%0D%0A++%3Felemtype+rdfs%3AsubClassOf+cmdm%3AElement.%0D%0AFILTER%28+isLiteral%28%3Fvalue%29%29%0D%0AFILTER%28+regex%28%3Fvalue%2C%27.%27%29%29%0D%0A}&format=text%2Fhtml&timeout=0&debug=on|elements with values for LexicalResourceProfile ]]