Skip to content

How to add a new Annotator

Michael Röder edited this page Nov 10, 2015 · 16 revisions

For adding a new annotator adapter to GERBIL, you should follow these steps

  1. Find the correct experiment type for your annotator. You might want to take a look on the list of experiment types.
  2. Choose the way GERBIL should communicate with your annotator.
    1. If your annotator can be accessed as a NIF-based web service, you already finished the implementation part. (highly recommended)
    2. Else, you will have to implement an adapter for your annotator.
  3. You might want to add the annotator permanently to GERBIL. This is optional if you have chosen 2.i.

Implement an adapter

You will have to write an adapter class that manages the communication with your annotator. This class should implement the interface according to the experiment type you have chosen.

Type Interface
A2KB org.aksw.gerbil.annotator.A2KBAnnotator
C2KB org.aksw.gerbil.annotator.C2KBAnnotator
D2KB org.aksw.gerbil.annotator.D2KBAnnotator
ERec org.aksw.gerbil.annotator.EntityRecognizer
ETyping org.aksw.gerbil.annotator.EntityTyper
OKETask1 org.aksw.gerbil.annotator.OKETask1Annotator
OKETask2 org.aksw.gerbil.annotator.OKETask2Annotator

You might want to have a look at the already existing adapter implementations that you can find in this package https://github.com/AKSW/gerbil/tree/master/src/main/java/org/aksw/gerbil/annotator/impl .

If you already have an adapter that fits to the BAT-Framework, it is possible to use this adapter with GERBIL, too. However, this is not recommended since the results using such a wrapper for a BAT-Framework adapter might be worse than implementing a new one.

Add the annotator permanently

If your annotator can be accessed as a NIF web service, you won't need to perform this step since you already can add your annotator as a NIF-based web service during the configuration of a GERBIL experiment. If you want to add it permanently or you have chosen to implement a new adapter class, you will have to add your annotator to the annotator.properties file.

Let's assume that we have a NIF-based web service that we want to add permanently. Than we could add the following lines to the properties file.

### My own annotator (MOA)
org.aksw.gerbil.annotator.MOA.annotateURL=http://example.org/annotate
org.aksw.gerbil.annotators.definition.MOA.name=My own Annotator
org.aksw.gerbil.annotators.definition.MOA.experimentType=A2KB
org.aksw.gerbil.annotators.definition.MOA.cacheable=true
org.aksw.gerbil.annotators.definition.MOA.class=org.aksw.gerbil.annotator.impl.nif.NIFBasedAnnotatorWebservice
org.aksw.gerbil.annotators.definition.MOA.constructorArgs=${org.aksw.gerbil.annotator.MOA.annotateURL}

It can be seen, that we have to define the name, the experiment type, a flag whether the results should be cached, the class of the annotator and the constructor arguments for that class. Note that these constructor arguments are always interpreted as Strings and should be comma separated.

In some special cases it might be useful to define an annotator multiple times. Let's assume that our annotator can perform not only the A2KB task but it has an additional URL for linking entities (D2KB). Thus, we have to define it a second time. Note that this second definition is necessary, because we use two different URLs for the different tasks. If we would use always the same URL, this second definition is not needed since every A2KB annotator can be used in a D2KB experiment.

org.aksw.gerbil.annotator.MOA.linkURL=http://example.org/annotate
org.aksw.gerbil.annotators.definition.MOA2.name=My own Annotator
org.aksw.gerbil.annotators.definition.MOA2.experimentType=D2KB
org.aksw.gerbil.annotators.definition.MOA2.cacheable=true
org.aksw.gerbil.annotators.definition.MOA2.class=org.aksw.gerbil.annotator.impl.nif.NIFBasedAnnotatorWebservice
org.aksw.gerbil.annotators.definition.MOA2.constructorArgs=${org.aksw.gerbil.annotator.MOA.linkURL}

It can be seen that our second annotator definition has different keys (*.MAO2.* instead of *.MAO.*) but the same name as the first one. Thus, GERBIL identifies this as the same annotator but as a different configuration for another experiment type.