Search code examples
uimaruta

Need to assign feature value of A annotation to B based on some condition -uima ruta


Annotation A has 3 features namely, name, date & index. Annotation B has 3 features namely, name, date & index. Values are assigned to all the features except B.index. Matching name & date of A & B, I want to assign A.index to B.index

Sample output:

A annotaion:

   Wardlaw
      name:Wardlaw
      date:2003
      index:3
   Rahul
       name:Rahul
       date:1993
       index:4


B annotaion:

   Rahul
       name:Rahul
       date:1993
       index:0

   Wardlaw
       name:Wardlaw
       date:2003
       index:0

Expected Output:

B annotaion:

   Rahul
       name:Rahul
       date:1993
       index:4

   Wardlaw
       name:Wardlaw
       date:2003
       index:3

Solution

  • You can try something like:

    a:A{a.name == b.name, a.date == b.date} # b:@B{ -> b.index = a.index};
    

    I put the anchor on B so that no B is missed. The condition need to be placed at A so that the wildcard stops at the correct annotation.

    If the As and the Bs share the same offset, you need another, simpler rule with only one rule element and no wildcard..

    DISCLAIMER: I am a developer of UIMA Ruta