How to select and set a covering/covered annotation as a feature in RUTA

48 views Asked by At

I have a Ruta rule that looks something like this, where dep is a DKPro imported Dependency type.

dep{}->{MyItem{->
        SETFEATURE("Display", "displayedValue"),
        SETFEATURE("Lemma", dep.Dependent.lemma.value),
        SETFEATURE("Parent", dep.Governor)};};

The first two actions work. The problem I have is in the third action SETFEATURE("Parent", dep.Governor). dep.Governor returns a Token type but my feature requires another type that happens to share the same location as the Governor. In other words I want my own type, not dep.Governor, that has already annotated that governing word.

I am unsure how to recover an annotation (my annotation) that occupies the same space as the dep.Governor. Ideally I would like to recover it as a variable so that I can reuse it for other features to do something like this.

a:MyItem [that overlaps dep.Governor]

dep{}->{MyItem{->SETFEATURE("Parent", a)};};

Here is a more precise example

d:dep.Dependency{->
    MyItem, 
    MyItem.Display = "Ignore",
    MyItem.Lemma = d.Dependent.lemma.value,
    MyItem.LanguageParent = d,                              
};

The line MyItem.LanguageParent = d produces this Ruta error

Trying to access value of feature "type.MyItem:LanguageParent" as "type.MyItem", but range of feature is "de.tudarmstadt.ukp.dkpro.core.api.syntax.type.dependency.Dependency"
1

There are 1 answers

2
RodP On

I am sure there is a cleaner way than this, but for now, I am converting the type using a block function and saving it into an annotation variable.

BLOCK(ConvertTokenToMyItem) Token{IS(MyItem)} {
    varMyItem:MyItem;          
}

Then I use it

d:dep.Dependency{->
    MyItem, 
    MyItem.Display = "Ignore",
    MyItem.Lemma = d.Dependent.lemma.value,
    MyItem.LanguageParent = varMyItem,                              
};