TL;DR
How to easily deploy your Apache RUTA project as a web service. No (Java) coding required :-)
- dowload release, unzip and
cdinto it - configure
application.propertiesand make it point to your RUTA project - start server
bin/ruta_serverand check it athttp://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 supportandApache 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.
- File > New > UIMA Ruta project, let's call it
-
Create a RUTA script
- Click on the
scriptfolder inruta_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?;
- Click on the
-
Add a sample document
mytest.txtininputfolder, with the following contentThe 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
- Select Type System
- Click on Eclipse View
Annotation Browser View(tabed window on the right)- Select checkboxes with the
Yearannotation
- Select checkboxes with the
- 1956 only should be highlighted
Now, let's start RUTA-server
- First, dowload the release, unzip it and
cdinto 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- The web service is at http://localhost:8566/annotate.json
- I also created a small html demo
comments powered by Disqus