Search code examples
uimaruta

How to access value of an annotation contained in a UIMA RUTA rule


I'm not sure if I'm doing this wrong, but I have this case. I have a list of words "stuff.txt" (for example), contains knife, fork, spoon

Then a script like this DECLARE Stuff(INT count); Document{-> MARKFAST(Stuff, StuffList, true)}; NUM Stuff -> Update stuff count

And then, in my text most of the time I'll have something like 3 knifes, 2 spoons for example.

Is there a way to get the number value and update the annotation ? Or use gather to update the annotation itself ? Assign the NUM annotation.ct to my Stuff.count value or something of that sort without creating another type like DECLARE NewStuff(Stuff stuff, INT count) and use gather.


Solution

  • This should do what you want:

    DECLARE Stuff(INT count);
    Document{-> MARKFAST(Stuff, {"knifes", "spoons"}, true)};
    INT amount;
    NUM{PARSE(amount)} s:@Stuff{-> s.count = amount};
    

    The PARSE condition is used to convert the covered text to an integer.

    DISCLAIMER: I am a developer of UIMA Ruta