Hi Adam,

Thanks for the given example ! it's a month that i have started working with
UIMA API and i can't until now understand what the value added of UIMA ?

for example :
if I want to use external resource and check if an entity in the external
resource is matched in the given CAS document ? why sould I write a
tokenizer and other thing of java code to do so
Why UIMA doesn't offer this possibility directly whithout any other java
code ?

-Yassine

2007/3/22, Adam Lally <[EMAIL PROTECTED]>:

On 3/15/07, LASRI YASSINE <[EMAIL PROTECTED]> wrote:
> 2007/3/15, Michael Baessler <[EMAIL PROTECTED]>:
> >
> > LASRI YASSINE wrote:
> > > Exactly what I need, but rule can be either regular expression or
> > > aggregation of premitifs annotators ?
> > > Have any example ?
> > When I understand you correct, you want to have a rules that says:
> >
> > rule1:  [person] /meets/ [person]
> >
> > where the rules consist of a person annotation followed by a regular
> > expression "meets" followed by another person annotation.
> > Is that what you mean by "either regular expression or aggregation of
> > premitifs annotators"?
>
>
> > Yes of course that's what I mean !
>
> Sorry I haven't got any example or implementation that do such kind of
> > processing. Maybe some other users on the users list can help you here
> > if they have some experience.
>
>
> > If any user have an example, please send it to me
>

I don't have a ready-to-run example, but to get yourself started I
would do something like this:

   FSIndex personIndex = aJCas.getAnnotationIndex({Person.type);
   //iterate over pairs of Person annotations
   Iterator personIter = personIndex.iterator();
   while (personIter.hasNext()) {
     Person person1 = (Person)personIter.next();
     if (!personIter.hasNext())
       break;
     Person person2 = (Person)personIter.next();
     if (person1.getEnd() < person2.getBegin()) {
       //check if the text between the annotations contains the word
"meets"
       //(this could easily be a regular expression match instead, of
course)
       String textBetween =
aJCas.getDocumentText().substring(person1.getEnd(),
             person2.getBegin());
       if (textBetween.indexOf("meets") > -1) {
         //create annotation
         MeetsRelationAnnotation newAnnot = new
MeetsRelationAnnotation(aJCas,
           person1.getBegin(), person2.getEnd());
         newAnnot.addToIndexes();
       }
    }
  }

Note I just typed that right into this email, so there might be syntax
errors.  But it should give you the idea.

Now if you want to turn this into a more general annotator that you
can configure with arbitrary rules that tell it what to match, then
that's a much more complex question.  What we can help you with here
is how to use the UIMA APIs.

Regards,
-Adam

Reply via email to