Search code examples
uimaruta

Unmark previously marked annotation while marking related one


Here is my input:

person
the private person

Here are my rules

DECLARE Person;
DECLARE PrivatePerson;

ANY{REGEXP("person") -> MARK(Person)};

ANY{AFTER(Person), REGEXP("private") -> MARK(PrivatePerson), UNMARK(Person)};

How can I make Person in "private person" unmarked (but leave PrivatePerson marked)?

UNMARK(Person) does not work

Is it possible at all?


Solution

  • I don't know if the following suits you but it'll work:

    W{REGEXP("private")} Person {->UNMARK(Person),MARK(PrivatePerson,1,2)};
    

    I put 1,2 so that the annotation span contains private too.

    On your conditions, you need to have BEFORE not AFTER. That will create an annotation PrivatePerson. However, the unmarking won't happen because of the fact that the rules only apply to what is matched. What is matched in your rule is the string "private" and nothing else. The BEFORE(Person) is just a condition, so the rule UNMARK(Person) in the specific occasion does nothing.

    Also, prefer Document instead of ANY, because ANY goes to every token (for me it is both RutaBasic and SW) and creates duplicate annotations, whereas with Document I end up with one instance of each. I'm not sure though if you experience the same behavior.