21 August 2014

←Home

Easily deploying Apache RUTA projects as web services

TL;DR

How to easily deploy your Apache RUTA project as a web service. No (Java) coding required :-)

  • dowload release, unzip and cd into it
  • configure application.properties and make it point to your RUTA project
  • start server bin/ruta_server and check it at http://localhost:8566/index.html

Apache RUTA

Ruta (site, documentation) is a workbench to write NLP rules and test them. Apache RUTA is a great tool, and to expose it as a REST service (and thus allowing to annotate text), I created RUTA-server. It works with Linux, OS X, Windows, and requires a Java Runtime (1.7 or higher).

First, let's create an Apache RUTA project:

  • If you don't already have it: install Eclipse (download), or use your own, if recent enough.
  • Install RUTA plugin
    • Help > Install New Software...
    • Work with: http://www.apache.org/dist/uima/eclipse-update-site/
    • Add...
      • Name: RUTA, OK
    • Select Apache UIMA Eclipse tooling and runtime support and Apache UIMA Ruta.
      • Next, Next, Finish
  • Open Ruta Perspective
    • Window > Open Perspective > Other...
    • Select: Uima Ruta
  • Create a new RUTA project
    • File > New > UIMA Ruta project, let's call it ruta_server_example.
  • Create a RUTA script

    • Click on the script folder in ruta_server_example.
    • File > New > UIMA Ruta File, let's call it Example.ruta.
    • Add the following rules
      DECLARE Year;
      // find something that maybe indicates the year: a number with four digits starting with 19 or 20
      NUM{REGEXP("19..|20..") -> MARK(Year,1,2)} PM?;
      
  • Add a sample document mytest.txt in input folder, with the following content

        The year 1956 should get annotated, but 21231 not (yet).
    
    • Run script
    • Open script script/Example.ruta
    • Right click, Debug As, UIMA Ruta
    • Open Console view to see progress, wait until it's <terminated>
    • View results
    • Open output/mytest.txt.xmi
      • Select Type System ExampleTypeSystem.xml
    • Click on Eclipse View Annotation Browser View (tabed window on the right)
      • Select checkboxes with the Year annotation
    • 1956 only should be highlighted

Now, let's start RUTA-server

  • First, dowload the release, unzip it and cd into it.
  • Then, configure application.properties
    • You need to specify the root path of the RUTA project. In our example, it is the folder in which you created the above RUTA project.
    • Also, you need to tell the name of the RUTA engine, in our case it is descriptor/ExampleEngine.xml
    • Also, we can specify which
  • Finally, start the server by typing in a terminal sh bin/ruta_server
Go Top
comments powered by Disqus