Design patterns for the representation of "annotations".
N-Ary Relation Pattern
Here is a design pattern for the representation of annotations on concepts and/or on one or more literals. In this case the annotation is represented as an n-ary relation between 0 or more concepts, 0 or more literals, and the content of the annotation.
First declare necessary vocabulary (assume conventional namespace prefixes) ...
# main annotation class skos:Annotation a rdfs:Class. # specific annotation types skos:ScopeNote a rdfs:Class; rdfs:subClassOf skos:Annotation. # etc. for other annotation types # property to link resources to annotations skos:annotation a rdf:Property; rdfs:range skos:Annotation. # property to link annotations to literals skos:annotatesLiteral a rdf:Property; rdfs:domain skos:Annotation; rdfs:range rdfs:Literal. # property to give text content to annotation skos:annotationContent a rdf:Property; rdfs:domain skos:Annotation; rdfs:range rdfs:Literal.
Now apply, e.g. ...
@prefix eg: <http://example.org/concepts#> . eg:A a skos:Concept; skos:prefLabel "foo"@en; skos:altLabel "bar"@en; skos:annotation [ a skos:Annotation; skos:annotatesLiteral "bar"@en; skos:annotationContent "The label 'bar' is only used on tuesdays."@en; ]; .
This framework can be extended to support multiple annotation scenarios, for example ...
@prefix x: <http://example.org/skos-extensions#>. # extended annotation type x:AcronymRelationship a rdfs:Class; rdfs:subClassOf skos:Annotation. # extended annotation links x:acronymForm a rdf:Property; rdfs:subPropertyOf skos:annotatesLiteral. x:fullForm a rdf:Property; rdfs:subPropertyOf skos:annotatesLiteral. # now use the extensions ... eg:B a skos:Concept; skos:prefLabel "toilet"@en; skos:altLabel "water closet"@en; skos:altLabel "WC"@en; skos:annotation [ a x:AcronymRelationship; x:acronymForm "WC"@en; x:fullForm "water closet"@en; skos:annotationContent "'WC' is an acronym for 'water closet'."@en; ]; .
... or e.g. ...
x:LiteralTranslation a rdfs:Class; rdfs:subClassOf skos:Annotation. eg:C a skos:Concept; skos:prefLabel "cat"@en; skos:altLabel "feline"@en; skos:prefLabel "chat"@en; skos:altLabel "féline"@fr; skos:annotation [ a x:LiteralTranslation; skos:annotatesLiteral "cat"@en; skos:annotatesLiteral "chat"@fr; ]; skos:annotation [ a x:LiteralTranslation; skos:annotatesLiteral "feline"@en; skos:annotatesLiteral "féline"@fr; ]; .
MIME Annotations
The above pattern only accounts for annotations that have plain text content. A framework to support annotations with content according to an arbitrary MIME type would be preferable. Assuming the following vocabulary has been declared somewhere ...
@prefix mime: <http://www.w3.org/somebodyshoulddothis/mime#>. mime:Message a rdfs:Class. mime:content a rdf:Property; rdfs:domain mime:Message; rdfs:range rdfs:Literal. mime:type a rdf:Property; rdfs:domain mime:Message; rdfs:range rdfs:Literal. mime:language a rdf:Property; rdfs:domain mime:Message; rdfs:range rdfs:Literal.
... this would allow the annotations pattern above to be modified slightly as follows ...
# declare range of annotation content as a MIME message skos:annotationContent a rdf:Property; rdfs:domain skos:Annotation; rdfs:range mime:Message.
... and then used as in e.g. ...
eg:D a skos:Concept; skos:prefLabel "The theory of general relativity"@en; skos:annotation [ a skos:ScopeNote; skos:annotationContent [ mime:content "As embodied by the well known equation E=MC^2."; mime:type "text/plain"; mime:language "en"; ]; skos:annotationContent [ mime:content """ As embodied by the well known equation <em>E</em> = <em>MC</em><sup>2</sup>. """^^rdfs:XMLLiteral; mime:type "application/xhtml+xml"; mime:language "en"; ]; ]; .
N.B. The above example invents an RDF vocabulary for describing MIME messages, which [AlistairMiles: AFAIK] does not exist. There is however an RDF vocabulary for describing HTTP messages. Rewriting the examples above using the HTTP vocab might give ...
@prefix http: <http://www.w3.org/2006/12/http#>. # declare range of annotation content as a MIME message skos:annotationContent a rdf:Property; rdfs:domain skos:Annotation; rdfs:range http:Response.
... and then used as in e.g. ...
eg:D a skos:Concept; skos:prefLabel "The theory of general relativity"@en; skos:annotation [ a skos:ScopeNote; skos:annotationContent [ http:body "As embodied by the well known equation E=MC^2."; http:content-type "text/plain"; http:content-language "en"; ]; skos:annotationContent [ http:body """ As embodied by the well known equation <em>E</em> = <em>MC</em><sup>2</sup>. """^^rdfs:XMLLiteral; http:content-type "application/xhtml+xml"; http:content-language "en"; ]; ]; .