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

Contents

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: http://www.w3.org/1999/02/22-rdf-syntax-ns#
  • RDFS: http://www.w3.org/2000/01/rdf-schema#

Dublin Core Annotator

It will provide a DublinCore annotator with the properties defined in: http://purl.org/dc/elements/1.1/

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);
        text.setContent("London.");
 
        // 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("http://sws.geonames.org/2643743/");
 
        // Create a geographic entity in the document from an external ontology
        geoa.startInnerAnnotatorOn(londonGeonamesURI);
 
        // We set RDFS labels
        // We set the language support in Official Aramaic ISO format
        geoa.startSpecifyLanguage("arc");
        // We write label in the Official Aramaic language 
        geoa.writeLabel("ܠܘܢܕܘܢ ");
 
        // Wet the language support in French ISO format
        geoa.startSpecifyLanguage("fr");
        // We write label in the French language
        geoa.writeLabel("La ville de Londres");
 
        // We set the overwrite mode to reset the french label
        geoa.setAppendMode(false);
 
        // We overwrite a label 
        geoa.writeLabel("Londres");
 
        // We set back the append mode of the annotator 
        geoa.setAppendMode(true);
 
        // We remove language specification 
        geoa.endSpecifyLanguage();
        // we write a label without language attribute
        geoa.writeLabel("London");
 
 
        // We set geonames specific latitude/longitude properties
        geoa.setWgs84_pos_lat(51.50051);
        geoa.setWgs84_pos_long(-0.12883);
 
        // Create add segment on the Text
        LinearSegment segment = new LinearSegment();
        segment.setStart(0);
        segment.setEnd(6);
        segment.setUri(segmentURI.toString());
        text.getSegment().add(segment);
 
        // Create a semantic link between the segment and the geographical entity
        wpa.startInnerAnnotatorOn(segmentURI);
        wpa.writeRefersTo(londonGeonamesURI);

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="http://weblab-project.org/core/model/text" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <annotation uri="weblab://idfact/myDoc#a0">
        <data>
            <rdf:RDF xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
                <rdf:Description about="http://sws.geonames.org/2643743/" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
                    <rdfs:label xml:lang="arc">ܠܘܢܕܘܢ </rdfs:label>
                    <rdfs:label xml:lang="fr">Londres</rdfs:label>
                    <rdfs:label>London</rdfs:label>
                    <geo:lat>51.50051</geo:lat>
                    <geo:long>-0.12883</geo:long>
                </rdf:Description>
 
                <rdf:Description about="weblab://idfact/mySegment" xmlns:wprocessing="http://weblab-project.org/core/model/processing#">
                    <wprocessing:refersTo rdf:resource="http://sws.geonames.org/2643743/"/>
                </rdf:Description>
            </rdf:RDF>
        </data>
    </annotation>
    <segment xsi:type="ns3:linearSegment" uri="weblab://idfact/mySegment">
        <start>0</start>
        <end>6</end>
    </segment>
    <content>London.</content>
</resource>
Personal tools
WebLab Project