Table of Contents

<!–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 server-side implementation for a basic annotation task. The steps explained here correspond to Eclipse 3.7. This portion of the tutorial assumes that you've already worked through Creating an Annotation Task.

Create Server Package

In the Ccash Project:

This operation should create the package edu.byu.nlp.ccash.tasks.demo.server.

Create an Annotation Manager

Create the Annotation Manager

In the Ccash Project:

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

Specify Generic Parameters

JavaAnnotationManager 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 DemoAnnotationManager extends JavaAnnotationManager<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:

Example Code

Here is a complete implementation of DemoAnnotationManager:

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

import java.util.List;
import java.util.Map;
import java.util.UUID;

import edu.byu.nlp.ccash.annotation.server.java.AnnotationManagerJavaReturnValue;
import edu.byu.nlp.ccash.annotation.server.java.AutomaticAnnotationProviderJavaReturnValue;
import edu.byu.nlp.ccash.annotation.server.java.BasicAnnotationManagerJavaReturnValue;
import edu.byu.nlp.ccash.annotation.server.java.JavaAnnotationManager;
import edu.byu.nlp.ccash.client.CcashException;
import edu.byu.nlp.ccash.client.datatransferobjects.DBTimelineEventDTO;

public class DemoAnnotationManager extends JavaAnnotationManager<String, String> {

	@Override
	protected AnnotationManagerJavaReturnValue<String, String> nextPreannotatedJavaInstance(
			long annotatorId, long instanceProviderId, long projectIterationId,
			Map<String, String> configuration) throws CcashException {
	
		String instance = "UniqueInstance"+UUID.randomUUID().toString();
		AnnotationManagerJavaReturnValue<String, String> retVal = BasicAnnotationManagerJavaReturnValue.okayRetval(-1L, instance);
		return retVal;
	}

	@Override
	protected AutomaticAnnotationProviderJavaReturnValue<String, String> updateJavaAnnotation(
			String instanceValue, String annotationConstraint, long instanceId,
			long annotatorId, long automaticAnnotationProviderId,
			long projectIterationId, Map<String, String> configuration)
			throws CcashException {

		// No automatic updates to perform
		return null;
	}

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

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

	@Override
	protected Long javaAnnotationReceived(long aiId, String annotation,
			long instanceId, long annotatorId,
			List<DBTimelineEventDTO> timelineEvents, long projectIterationId,
			long annotationManagerId,
			Map<String, String> annotationManagerConfiguration)
			throws CcashException {

		// log annotations to the command line		
		System.out.println(
				"Received annotation: " + annotation +
				" id: " + aiId +
				" on instance: " + instanceId +
				" from annotator: " + annotatorId);
		return null;
	}

	@Override
	protected void startManager(long projectId,
			Map<String, String> configuration) throws CcashException {
		// ignore
	}

	@Override
	protected Map<String, String> getDefaultManagerConfiguration() {
		// no configuration
		return null;
	}
}

Register Annotation Manager as a Network Service

Add a mapping for your class in the Ccash/src/org/apache/xmlrpc/webserver/XmlRpcServlet.properties file as follows:

DemoAnnotationManager=edu.byu.nlp.ccash.tasks.demo.server.DemoAnnotationManager

Advanced

In fact, Annotation Managers are just convenience wrappers around three internal structures: instance providers, automatic annotation providers, and annotation recorders. If you find yourself wanting to separate an annotation manager into reusable classes, you may do so by implementing these pieces separately, then assembling them in the Project wizard by selecting the “Advanced” tab.

In a typical annotation scenario, Ccash would query an instance provider for an instance, then ask an automatic annotation provider to make a guess at the correct labeling before presenting the pre-annotated instance to a human annotator via a compatible GUI task. After the annotator finished correcting the guess, the completed annotation would be sent to a set of annotation recorders to be preserved.

Other Languages

Find an xmlrpc implementation for your language of choice, and implement the interfaces that you find documented in the following classes in the package edu.byu.nlp.ccash.annotation.server:

Or

For more insight to how these interfaces are intended to work, see the corresponding interfaces in the packages edu.byu.nlp.ccash.annotation.server.rawjava and edu.byu.nlp.ccash.annotation.server.java.