The MICO project is about extracting information of various kinds from a broad range of media types
like images, video, sound, and text. This information is represented in a unified data model, which is based on W3C recommendation efforts around web annotations. To retrieve parts of such information that satisfy use case specific
needs users require a well defined toolkit for query formalization. We mainly separate here 2 different query mechanism for RDF, that we developed / extended within the Mico:

SPARQL

The W3C SPARQL 1.1 recommendation defines the syntax and semantics of the SPARQL query language for RDF. It fits many use case scenarios and is denoted as the de-facto query language for the Semantic Web. SPARQL queries manly consist of the following blocks:

  • PREFIX Prefixes allow to shorten URLs. They are optionally defined on the top of a SPARQL query.
  • PROJECTION This block represents the projection part of the language. SPARQL allows 4 different kind of projection:
    • SELECT, CONSTRUCT, DESCRIBE, and ASK.
  • DATASET This block allows to specify the context(s) in which the query is evaluated.
  • SELECTION This block (WHERE) may contain triple patterns, optional clauses, existence checks and filters.
  • LIST OPS This block allows result ordering (ORDER BY) and segmentation (OFFSET,LIMIT). AGGREGATION This block allows result aggregation (GROUP BY, HAVING).

The figure shows a SPARQL query that lists all classes (types) and their number of appearances.

SELECT ?class (COUNT(?class) as ?number)
WHERE {
[] a ?class .
}
GROUP BY ?class

A wider set of SPARQL examples can be found in the Mico Technical Report Volume 3.

SPARQL-MM

SPARQL-MM is a Multimedia Extension for SPARQL. The extension includes relation, aggregation and accessor functions for media fragments but is under continuous development. A complete function list if the current version (SPARQL-MM 2.0) can be found in the Mico Technical Report Volume 5 and on the code repository of the reference implementation.

The following examples show some simple SPARQL-MM queries. Example one presents a spatial relation.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX mm: <http://linkedmultimedia.org/sparql-mm/ns/2.0.0/function#>
SELECT ?t1 ?t2 WHERE {
?f1 rdfs:label ?t1.
?f2 rdfs:label ?t2.
FILTER mm:rightBeside(?f1,?f2)
} ORDER BY ?t1 ?t2

Example two shows a temporal accessor.

PREFIX ma: <http://www.w3.org/ns/ma-ont#>
PREFIX mm: <http://linkedmultimedia.org/sparql-mm/ns/2.0.0/function#>
SELECT ?f1 WHERE {
?f1 a ma:MediaFragment.
} ORDER BY mm:duration(?f1)

Example 3 shows a spatio-temporal aggregation.

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX mm: <http://linkedmultimedia.org/sparql-mm/ns/2.0.0/function#>
SELECT ?f1 ?f2 (mm:boundingBox(?f1,?f2) AS ?box) WHERE {
?f1 rdfs:label "a".
?f2 rdfs:label "b".
}

LDPath

In some cases SPARQL is not the best solution for all use cases due to its complexity and steep learning
curve. Especially when projects try to hide such complexity in order to be attractive to a broad community
there is a need of solutions that offer a good tradeoff between feature completeness and simplicity
in usage. LDPath, a path traversal language similar to XPath or SPARQL Property Paths is such a straight-forward candidate. In Mico we use it internally for Anno4J filter mechanism. Additionally it is available via Marmotta webservices. The figure shows a LDPath query that returns the labels of all extracted topics for a single content item.

@prefix mico: <https://www.mico-project.eu/ns/platform/1.0/schema#> ;
@prefix oa: <http://www.w3.org/ns/oa#> ;
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ;
@prefix fam: <http://vocab.fusepool.info/fam#> ;
annotation = mico:hasContentPart/mico:hasContent/oa:hasBody[rdf:type is fam:TopicAnnotation]/fam:topic-label :: xsd:string ;

More LDPath examples can be found in the Mico Technical Report Volume 5.