I have written a UIMA annotation engine in Java and I want to move the rules out of Java into RUTA. One of the things my Java engine does is process the words and apply rules in a particular order which is a different order to the words in the sentence.
Using an example sentence "The system requests a username and password." would not be processed in that order. Instead my rules are applied based on the structure of the Dependency annotations, so the sentence is instead processed in this order [requests, The, system, username, ., a, and, password]
I was therefore wondering if there is an easy way to apply RUTA rules in a different order, without reordering the CAS, perhaps using an index? I could continue to use Java to create an index annotation like this: The(2) system(3) requests(1) a(6) username(4) and(7) password(8).(5) but I can't figure out how to use the forEach BLOCK or some other RUTA logic to process these in the index order.
If you are wondering why I need to process them in order, the reason is that the application of my rules requires the Dependency hierarchy. The annotation of the dependent is driven by the annotation of the governor/parent.
I found a way of doing this using blocks. Since blocks can be recursive, I create a child block first, which looks up the items parent, and then calls the parent block. For example using the dependency structure I can annotate the governor before the dependent (with special logic when you get to the ROOT).
d:dep.Dependency{d.DependencyType!="ROOT"}->{
d.Governor{-IS(MyItem)}->{
CALL(myPackage.AnnotateGovernor);
};
};