Reputation: 1054
I need to match the feature of an annotation and to also need to mark the second annotation of the matched feature. I've tried it but I'm facing two issues
ISSUE 1:
SEPERATEDA annotation values got reduced.I think its due to dictRemoveWS.
ISSUE 2:
It showing only the last match.(Due to some looping problem).
Sample file 1:
Arash Alipour
Rahul Bhargava
Lisette I.S. Wintgens
B. Rahul
Alipour A
Ali Aldabahi
M. Naziruddin Khan
Martin J. Swaans
Naziruddin Khan
Expected Output for file 1:
Rahul
Alipour
Naziruddin
Khan
Sample file 2:
M. Naziruddin Khan
Arash Alipour
Rahul Bhargava
Lisette I.S. Wintgens
Alipour A
Ali Aldabahi
M. Naziruddin Khan
Expected Output for file 2:
Alipour
Naziruddin
Khan
My Script:
PACKAGE uima.ruta.example;
DECLARE SINGLEINITIAL;
CW{REGEXP(".")->MARK(SINGLEINITIAL)};
DECLARE SeperateDA;
DECLARE DA;
"Arash Alipour"->DA;
"Lisette I.S. Wintgens"->DA;
"Alipour A"->DA;
"Rahul Bhargava"->DA;
"M. Naziruddin Khan"->DA;
"B. Rahul"->DA;
"Ali Aldabahi"->DA;
"A. S. Al Dwayyan"->DA;
"Lucas V.A. Boersma"->DA;
"Jippe C. Bal"->DA;
"Benno J.W.M. Rensing"->DA;
"Martin J. Swaans"->DA;
BLOCK(DocAuth) DA{}
{
CW{-PARTOF(SINGLEINITIAL)-> MARK(SeperateDA)};
}
DECLARE RepeatedDA(STRING auth);
STRING MatchedAuth;
SeperateDA{->MARK(RepeatedDA),MATCHEDTEXT(MatchedAuth)}->{RepeatedDA{->RepeatedDA.auth=MatchedAuth};};
STRING auth;
FOREACH(RepAuth) RepeatedDA{}
{
(da1:RepeatedDA {->UNMARK(RepeatedDA)}# da2:RepeatedDA){da1.auth != da2.auth};
}
I also tried something like this
da:RepeatedDA{->da.auth = RepeatedDA.auth};
FOREACH(RepAuth, true) RepeatedDA{}
{
# da:RepeatedDA{->auth = da.auth, LOG(" auth-" +auth)};
da:RepeatedDA {auth != da.auth-> UNMARK(da)};
}
My goal is to remove the more over similar name from DA. For example from the above sample file both Rahul Bhargava and B. Rahul are in DA.But I need only Rahul Bhargava to be in DA.
Upvotes: 1
Views: 160
Reputation: 3113
There seems to be a problem with your rule logic.
da1:RepeatedDA # da2:RepeatedDA
da2 match always on the directly next RepeatedDA/SeperateDA since the value of the auth feature differs. Thus, the rule applies to often, almost every time.
Try this:
DECLARE SINGLEINITIAL;
CW{REGEXP(".")->MARK(SINGLEINITIAL)};
DECLARE SeperateDA (STRING auth);
DECLARE DA;
"Arash Alipour"->DA;
"Lisette I.S. Wintgens"->DA;
"Alipour A"->DA;
"Rahul Bhargava"->DA;
"M. Naziruddin Khan"->DA;
"B. Rahul"->DA;
"Ali Aldabahi"->DA;
"A. S. Al Dwayyan"->DA;
"Lucas V.A. Boersma"->DA;
"Jippe C. Bal"->DA;
"Benno J.W.M. Rensing"->DA;
"Martin J. Swaans"->DA;
BLOCK(DocAuth) DA{}
{
CW{-PARTOF(SINGLEINITIAL)-> CREATE(SeperateDA, "auth" = CW.ct)};
}
DECLARE RepeatedDA;
da1:SeperateDA{-> RepeatedDA} # da2:SeperateDA{da1.auth == da2.auth};
DISCLAIMER: I am a developer of UIMA Ruta
Upvotes: 1