<!–Style guidelines: 1. Quote excerpts from Eclipse; commands, sections names, etc. 2. Italicize arguments: package names, class names, etc.

  remember that italics are placed on text delineated with 2 apostrophes: ''italicized words''
–> This page walks you through the steps necessary to creating the client-side interface for a basic annotation task. The steps explained here correspond to Eclipse 3.7.

Create a Module

In the Ccash project:

  • Click “New”→“Other”→“Google Web Toolkit”→“Module”
  • Click “Next”
  • Set “Package” to edu.byu.nlp.ccash.tasks.demo
  • Set “Module name” to Demo
  • In the “Inherited modules” section, remove the com.google.gwt.user.User module and add edu.byu.nlp.ccash.Ccash
  • Click “Finish”

This operation should create two packages and one file:

  • Package: edu.byu.nlp.ccash.tasks.demo
  • Package: edu.byu.nlp.ccash.tasks.demo.client
  • File: Demo.gwt.xml in the package edu.byu.nlp.ccash.tasks.demo.

Create an Annotation Task

Create the Task

In the Ccash project:

  • Select the package edu.byu.nlp.ccash.tasks.demo.client
  • Click “New”→“Class”
  • Set “Name” to DemoTask
  • Set “Superclass” to edu.byu.nlp.ccash.annotation.client.AbstractAnnotationTask
  • Uncheck “Inherited abstract methods”
  • Click “Finish”

This operation should create the file DemoTask.java in the package edu.byu.nlp.ccash.tasks.demo.client.

Specify Generic Parameters

AbstractAnnotationTask takes two generic parameters, I for the class of instances that you will be annotating, and A for the class of annotations you will be producing. For this tutorial, set both to String as follows:

public class DemoTask extends AbstractAnnotationTask<String, String>

Implement Methods

Hover your mouse over the class name and click “Add unimplemented methods,” and then seven methods stubs should be generated. If you didn't uncheck “Inherited abstract methods” when you created the task, then the methods were auto-generated; you'll need to change some of the Object types to the more specific types for the generic types I and A (For this tutorial String).

The purposes of these methods are:

  • getDefaultInstanceProviderName: allows you to specify the name of the instance provider that you expect to be using with this task.
  • annotateInstanceDelegate: is the meat of the annotation task. In this method, your task is passed a container panel in which to display itself. It is also passed an instance, an automatic annotation, and a set of callback methods that it may use to alert the framework to various outcomes. Calling the finishedCallback commits the current annotation and retrieves the next. Calling the annotationChangeHandler alerts the framework that the annotation has changed, so the framework might query the automatic annotation provider for an updated annotation. Calling the annotationTaskValidator tells the framework whether or not the current annotation is in a valid state, so that it can enable or disable the commit button. In this method you will want to construct your GUI and load it into the container panel. For help on how to construct a GUI in GWT, see GWT documentation.
  • onCommitButtonClick: alerts you when the commit button has been clicked. If your annotation is in an invalid state you may throw an IncompleteAnnotationException.
  • postprocessCompletedAnnotation: allows you to do post-processing on a completed annotation. For this tutorial we'll leave it blank.
  • receiveUpdateAutomaticAnnotation: alerts your application to an updated automatic annotation. For this tutorial we'll leave it blank.
  • getInstanceClass: should return the class type of the instances you'll be annotating. This allows GWT to automatically serialize and deserialize your instance object. For this tutorial return String.class.
  • getAnnotationClass: should return the class type of the annotations you'll be producing. This allows GWT to automatically serialize and deserialize your annotation object. For this tutorial return String.class.

Example Code

Here is a complete implementation of DemoTask:

package edu.byu.nlp.ccash.tasks.demo.client;

import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;

import edu.byu.nlp.ccash.annotation.client.AbstractAnnotationTask;
import edu.byu.nlp.ccash.client.datatransferobjects.DBAnnotationInstanceDTO;
import edu.byu.nlp.ccash.common.client.events.CompletedHandler;
import edu.byu.nlp.ccash.common.client.events.ValueChangedHandler;

public class DemoTask extends AbstractAnnotationTask<String, String> {
	private TextBox labelDisplay;
	public DemoTask() {
		labelDisplay = null;
	public String getDefaultInstanceProviderName() {
		return "DemoInstanceProvider";

	protected void annotateInstanceDelegate(AcceptsOneWidget container,
			String instanceValue,
			String automaticAnnotationValue,
			CompletedHandler<String> finishedCallback,
			ValueChangedHandler<String> annotationChangeHandler,
			AnnotationValidatorCallback annotationTaskValidator,
			DBAnnotationInstanceDTO annotationInstance) {
		// Display instance
		Label instanceDisplay = new Label();

		// Display annotation
		labelDisplay = new TextBox();
		// Combine them in a parent panel
		FlowPanel panel = new FlowPanel();
		// Add the parent panel to the container

	protected String onCommitButtonClick() throws IncompleteAnnotationException {
		if (labelDisplay == null) {
			throw new NullPointerException("annotateInstanceDelegate should be called before onCommitButtonClick");
		String annotation = labelDisplay.getText();
		if (annotation.isEmpty()) {
			throw new IncompleteAnnotationException();

		return annotation;
	protected void postprocessCompletedAnnotation(String annotation) {
		// ignore

	protected void receiveUpdateAutomaticAnnotation(String automaticAnnotation) {
		// ignore

	protected Class<String> getInstanceClass() {
		return String.class;

	protected Class<String> getAnnotationClass() {
		return String.class;

Create an Entry Point

Create the Entry Point

In the Ccash project:

  • Select your module Demo.gwt.xml in the package edu.byu.nlp.ccash.tasks.demo
  • Click “New”→“Other”→Google Web Toolkit“→“Entry Point Class”
  • Click “Next”
  • Set “Name” to DemoEntryPoint
  • Set “Superclass” to edu.byu.nlp.ccash.annotation.client.AnnotationTaskEntryPoint
  • In the “Interfaces” section, remove EntryPoint
  • Click “Finish”

This operation should create one file and add a line to the module definition:

  • File: DemoEntryPoint.java in the package edu.byu.nlp.ccash.tasks.demo.client.
  • Module: in Demo.gwt.xml should add an entry-point element with an attribute of class with a value of edu.byu.nlp.ccash.tasks.demo.client.DemoEntryPoint. The following is a complete definition for the demo module:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.4.0//EN"
<module rename-to="demo">
	<inherits name="edu.byu.nlp.ccash.Ccash" />
	<source path="client" />

Implement Methods

Three method stubs should have been automatically generated. The purposes of the methods are:

  • getTaskName: should return the name of your task. This name must be unique among the tasks plugged into CCASH.
  • getTaskDescription: allows you to provide a description of your task. Return an empty string if the task has no description.
  • getAnnotationTask: should return an instance of your GUI annotation task. For this tutorial it should return an instance of DemoTask.

Example Code

Here is a complete implementation of DemoEntryPoint:

package edu.byu.nlp.ccash.tasks.demo.client;

import edu.byu.nlp.ccash.annotation.client.AnnotationTaskEntryPoint;
import edu.byu.nlp.ccash.annotation.client.AnnotationTaskInterface;

public class DemoEntryPoint extends AnnotationTaskEntryPoint {
	protected String getTaskName() {
		// replace with task name
		return "Demo Annotation Task";

	protected String getTaskDescription() {
		// replace with task description
		return "This is the description of the " + getTaskName() + " task";

	protected AnnotationTaskInterface<?, ?> getAnnotationTask() {
		// create the task and return it
		AnnotationTaskInterface<String, String> task = new DemoTask();
		return task;


Connect the Pieces

Add your module to CCASH's main module

Now edit the main module edu.byu.nlp.ccash.Ccash.gwt.xml to add an “inherits” reference to your newly created module.

<inherits name='edu.byu.nlp.ccash.tasks.demo.Demo' />

Update Eclipse Runtime Configuration

Because you have added a module to the main module, your run configuration will need to change so that the arguments includes your new module. The easiest way to do this is to delete your old “Ccash” run configuration (if it existed) and then create a new one automatically by clicking on the Ccash project then clicking “Run as”→“Web Application.”

Now you can proceed to Creating an Annotation Manager. After that, you should be able to make a CCASH project from the pieces that you've constructed (see Setting Up a Simple Sentiment Classification Task for an example of how to assemble exiting tasks and annotation managers).

Alternate Base Classes

This example chose to extend AbstractAnnotationTask. However, you can choose to directly implement AnnotationTaskInterface, or to extend other tasks that offer different pre-baked feature sets:


  • automatic (de)serialization
  • (optional) logs user interactions
  • (optional) queries annotation manager for updated annotations any time a user changes the annotation


  • pause button
  • commit button


  • facilitates implementing a sequence annotation (over an entire sentence).
nlp/creating-an-annotation-task.txt · Last modified: 2015/04/16 20:13 by ryancha
Back to top
CC Attribution-Share Alike 4.0 International
chimeric.de = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0