# UIMA Tcl Annotators and the Tclator

## What is a Tcl Annotator?

A Tcl Annotator is a UIMA annotator component written in Tcl that can be used within the UIMA SDK framework.

## What is the Tclator?

The Tclator is the linkage between the UIMA framework and a Tcl Annotator. The Tclator is actually a UIMA C++ annotator which can be referenced by primitive annotator or CAS consumer descriptors. The descriptor must define one configuration parameter, a second is optional:

`SourceFile` (mandatory) - a string holding the name of the Tcl module to run, and
`DebugLevel` (optional) - an integer value that specifies the debug level for tracing. Default value is 0. A value of 101 turns on Tclator tracing. Values 1-100 are reserved for annotator developer use.

When the Tclator is initialized, e.g. at CPE initialization, the C++ code creates a Tcl interpreter, imports the specified script and calls the script's initialization method. Similarly, when other Tclator methods such as process() are called by the UIMA framework, the associated methods in the Tcl script are called.

The Tclator also provides a Tcl library implementing an interface between Tcl and the UIMA APIs of the UIMA C++ framework.

## Supported Platforms

The Tclator has been tested with Tcl version 8.4 on Linux and with ActiveTcl8.4.13.0.261555-win32-ix86-threaded.exe on Windows XP.

## Prerequisites

The Tclator uses SWIG (http://www.swig.org/) to implement the Tcl library interface to UIMA. SWIG version 1.3.29 or later is required.

The UIMA C++ framework is required.

## Tclator Distribution

Tclator code is distributed in source form and must be built on the target platform.

Tclator source and sample code is located in the $UIMACPP_HOME/scriptators directory.

## Setting Environment Variables

The Tclator requires the standard environment for UIMA C++ components.

## Building and Installing the Tclator

Recursively copy the scriptators directory from the uimacpp distribution to a writable directory tree. CD to the writable scriptators/tcl directory.

### On Linux

- `Check that you have the required Tcl and Swig packages installed`
- `make`

### On Windows

- `Modify winmake.cmd to set the paths for your Tcl and Swig installs`
- `winmake`

Build results are the C++ annotator, tclator.so on Linux or tclator.dll on Windows.

If you have write access to UIMA C++ distribution tree, on Linux copy tclator.so to $UIMACPP_HOME/lib, and on Windows copy tclator.dll to $UIMACPP_HOME/bin.

If you don't have write access, make sure that tclator.so|.dll is in the LD_LIBRARY_PATH or PATH, as appropriate.

## Testing the Tclator

A simple Tcl regular expression annotator `sample.tcl` with descriptor `TclSample.xml` is included in the distribution. Use the descriptor as with any other UIMA annotator descriptor. Note that the Tcl script specified by the descriptor must be explicitly located, either with an absolute path or a path relative to the current directory of the running process.

## Known Tclator Issues

- Not all of the UIMA C++ APIs have been swig'ed. Missing functions can be added by extending the source file uima.i.
- UIMA Java components such as the CPE and the Vinci and SOAP service wrappers call analytics on different threads at different times. The Tcltator creates a "worker thread" for each Tcl analytic that is used to call into the interpreter.