Search code examples
uimaruta

Match all occurrences from the same dictionary in one line in UIMA RUTA


I have type Dog, which has features size, color and other

Size wordlist: big, medium, small

Other wordlist: old, fat, happy, lazy

Color wordlist does not affect anything in this case, so I won't list it.

And my code (just for the main file):

PACKAGE dog;

SCRIPT dog.Color;
SCRIPT dog.Size;
SCRIPT dog.Other;

TYPESYSTEM dogTypeSystemDescriptor;

ENGINE utils.PlainTextAnnotator;
TYPESYSTEM utils.PlainTextTypeSystem;

Document{-> CALL(Color)};
Document{-> CALL(Size)};
Document{-> CALL(Other)};

Document{-> EXEC(PlainTextAnnotator, {Line})};

Line{-> CREATE(Dog, "color" = Color, "size" = Size, "other" = Other)};

DECLARE Max, Milo;

Dog{Dog.color.ct == "black", 
    Dog.size.ct == "big" -> Max};

Dog{Dog.color.ct == "white", 
    Dog.other.ct == "fat" -> Milo};

As you can see on the picture, annotation "Milo" is never created (because it relies on the value "fat" of the feature "other" which is in the same dictionary with the "happy", but in the input word "happy" goes before "fat"). If we put "fat" before "happy" in the input - everything works as expected.

So, the question is how can I have annotations created for the each single feature from the same dictionary found in the same input?

enter image description here


Solution

  • Rafael has it right, but I would recommend an FSArray instead of the list. Here's an example tested with Ruta 2.6.1. Mind the "s" in feature "others" and its type FSArray.

    ENGINE utils.PlainTextAnnotator;
    TYPESYSTEM utils.PlainTextTypeSystem;
    
    // mock dictionary lookup and scripts
    DECLARE Color, Size, Other;
    "black|white" -> Color;
    "big|small" -> Size;
    "lazy|happy|fat" -> Other;
    
    DECLARE Dog (Color color, Size size, FSArray others);
    
    Document{-> EXEC(PlainTextAnnotator, {Line})};
    
    Line{-> CREATE(Dog, "color" = Color, "size" = Size, "others" = Other)};
    
    DECLARE Max, Milo;
    
    Dog{Dog.color.ct == "black", 
        Dog.size.ct == "big" -> Max};
    
    Dog{Dog.color.ct == "white", 
        Dog.others.ct == "fat" -> Milo};
    

    DISCLAIMER: I am a developer of UIMA Ruta