Search code examples
ruta

UIMA Ruta - match previous token


Given the example in the RUTA Guide:

DECLARE Sentence; PERIOD #{-> MARK(Sentence)} PERIOD;

I would like to include the first PERIOD in the sentence annotation, is that possible ?


Solution

  • Do you want the first period "." in the sentence annotation? You can do that with the following script.

    DECLARE Sentence;
    (PERIOD #){-> MARK(Sentence)} PERIOD;
    

    or

    DECLARE Sentence;
    (PERIOD #){-> Sentence} PERIOD;
    

    Using input: "my first sentence. And my second sentence."

    You will get ". And my second sentence" marked as sentence.

    Is that what you try to achieve? I don't think so ;-) I think you want real sentences with the dot at the end of the sentence?

    You can do that for example with:

    DECLARE Sentence;
    ((# PERIOD){-> Sentence })*;
    

    You will get: "my first sentence." and " And my second sentence." marked as sentence.