Created
December 23, 2011 09:54
-
-
Save renaud/1513763 to your computer and use it in GitHub Desktop.
Python test script for UIMA Jython Annotation Engine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Python imports. for now, only Python std library is possible | |
import re | |
# importing Java packages | |
# see http://wiki.python.org/jython/UserGuide#accessing-java-from-jython | |
from org.apache.uima.jcas.tcas import Annotation | |
# jcas object is made available to this script. use it like any python object. | |
text = jcas.getDocumentText(); | |
regex = re.compile("Dave"); | |
match = regex.search(text); | |
if (match): | |
# Create annotation and add it to jcas. This is then accessible from UIMA | |
annotation = Annotation(jcas, match.start(), match.end()); | |
annotation.addToIndexes(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment