Text extraction using RUTA scripts- Before and After conditions

62 Views Asked by At

I need to extract text which is between 2 keywords eg: Full Name XYZ123 Middle Name and I need . How to achieve this using BEFORE and AFTER conditions in RUTA script?

Tried something like below, but didn't work.

W{AFTER(W{ REGEXP("(?i)(Full)")}
        W{ REGEXP("(?i)(Name)")})};
1

There are 1 best solutions below

0
Peter Kluegl On

I recommend creating annotations for "Full Name" and for "Middle Name" and use a sequential pattern instead of the BEFORE/AFTER condition:

DECALRE FullName, MiddleName; "Full Name"->FullName; "Middle Name"->MiddleName; FullName #{->MyType} MiddleName; ...or... FullName ANY[0,5]{-PARTOF(MiddleName)->MyType} MiddleName;

I peronsally would recommend not to use these two conditions as there are always better solutions. If you do not want to specify new types and annotations, you could use literal string matching like:

"Full Name" #{->MyType} "Middle Name";