Annotator Documentation

From WebLab Wiki

Jump to: navigation, search

This page sums up the future usage of the WebLab Annotators.

The main goal of annotator is to ease the reading and writing of annotation on WebLab Resources (see a comparison between Annotator and Helpers). They provide some features:

  • to add and set annotation in a specific language (or without language support)
  • to manage typed values (instead of strings)
  • to manipulate easily non arbitrary number of values on a single property
  • to annotate WebLab Resources with properties defined in external ontologies

Annotators will be provided within WebLab Core 1.2:

  • RDF annotator
  • RDFS annotator
  • DublinCore annotator
  • WebLab Processing annotator
  • WebLab Retrieval annotator


Common Annotators Features

Language support

There is no language specified in an annotator by default.

  • startSpecifyLanguage(String lang)

Force the annotators to only read or write statements defined with the language lang.

  • endSpecifyLanguage()

Disable the limitation on the language.

Writing mode

  • setAppendMode(boolean append)

True by default, annotators use the append mode to add several annotations on the same property. If false, it will override already existing annotations.

  • isAppendMode()

return the current mode of writing (append mode is true by default).

Typed values

Managing typed values

The Java Value class behave as a typed value and a list of typed values at the same time.

External properties support

  • startInnerAnnotator(URI subject)
  • endInnerAnnotator()

RDF and RDFS Annotator

It will provide an annotator supporting the following properties:

  • RDF:
  • RDFS:

Dublin Core Annotator

It will provide a DublinCore annotator with the properties defined in:

WebLab Annotators

Using our provided tool OWL2javaWeblab, we generated annotators from WebLab processing and WebLab retrieval onologies.

Standard Use

Using our provided tool OWL2javaWeblab, the annotator WGeonamesAnnotator has been generated automatically from this little_geonames.owl.

 Text text = ResourceFactory.createResource("idfact", "myDoc", Text.class);
        // We can use several Annotator on a Resource at the same time
        WProcessingAnnotator wpa = new WProcessingAnnotator(text);
        WGeonamesAnnotator geoa = new WGeonamesAnnotator(text);
        // We create URI
        URI     segmentURI = new URI("weblab://idfact/mySegment");
        URI     londonGeonamesURI = new URI("");
        // Create a geographic entity in the document from an external ontology
        // We set RDFS labels
        // We set the language support in Official Aramaic ISO format
        // We write label in the Official Aramaic language 
        geoa.writeLabel("ܠܘܢܕܘܢ ");
        // Wet the language support in French ISO format
        // We write label in the French language
        geoa.writeLabel("La ville de Londres");
        // We set the overwrite mode to reset the french label
        // We overwrite a label 
        // We set back the append mode of the annotator 
        // We remove language specification 
        // we write a label without language attribute
        // We set geonames specific latitude/longitude properties
        // Create add segment on the Text
        LinearSegment segment = new LinearSegment();
        // Create a semantic link between the segment and the geographical entity

Once serialized, the resulting document in XML will be:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<resource xsi:type="ns3:text" uri="weblab://idfact/myDoc" xmlns:ns3="" xmlns:xsi="">
    <annotation uri="weblab://idfact/myDoc#a0">
            <rdf:RDF xmlns:rdfs="" xmlns:rdf="">
                <rdf:Description about="" xmlns:geo="">
                    <rdfs:label xml:lang="arc">ܠܘܢܕܘܢ </rdfs:label>
                    <rdfs:label xml:lang="fr">Londres</rdfs:label>
                <rdf:Description about="weblab://idfact/mySegment" xmlns:wprocessing="">
                    <wprocessing:refersTo rdf:resource=""/>
    <segment xsi:type="ns3:linearSegment" uri="weblab://idfact/mySegment">
Personal tools
WebLab Project