UIMA Ruta Creating annotation with features separated by some text - uima

I have some text with annotations created like the following:
wewf.werwfwef. wewfwefwwew. wefewefwff
AnnotationA
asdfawece aefae eafewfaefa aefafe ceaewfae
adfcaecae acaeaet aegaegageg caeacdaefa
AnnotationB
sadaeceaee aef aewfaegg rresf ceeaefaeaeaf
adfcaecae acaeaet aegaegageg caeacdaefa
AnnotationA
adfcaecae acaeaet aegaegageg caeacdaefa
adfcaecae acaeaet aegaegageg caeacdaefa
AnnotationB
adfcaecae acaeaet aegaegageg caeacdaefa
adfcaecae acaeaet aegaegageg caeacdaefa
I want to create an annotation with AnnotationA and its closest AnnotationB as features. How should I express this in Ruta?
I have tried the following incorrect way:
DECLARE Annotation TargetAnnotation (AnnotationA ana, AnnotationB anb);
Document {-> CREATE(TargetAnnotation, "ana" = AnnotationA, "anb" = AnnotationB)};
The rule covers the whole document. What I just want is annotation with AnnotationA and its closest AnnotationB as feature.
Thanks very much for any answer.

There are several ways to specify this in UIMA Ruta and they mainly depend on the offset the created TargetAnnotation should get. The CREATE action uses the span matched by the rule element in order to identify the values for the features.
If the offsets of the created annotation do not really matter, then you can simply use the span combining both annotations AnnotationA and AnnotationB:
(AnnotationA # AnnotationB){-> CREATE(TargetAnnotation, "ana" = AnnotationA, "anb" = AnnotationB)};
Mind that this rule introduces a sequential dependency between the two annotations. You can also specify rules that do not care, but they will probably return too many matches. It depends on what you want to accomplish.
If the offset of the created annotation should equal one of the provided annotations, e.g., AnnotationA, then you should use GATHER instead of CREATE. GATHER allows one to specify the index of the rule element whose match should be assigned to the feature.
AnnotationA{-> GATHER(TargetAnnotation, "ana" = 1, "anb" = 3)} # AnnotationB;
(I am a developer of UIMA Ruta)

Related

Using regexp with groups in Grafana

I have Grafana dashboards with “Stat” components and I try to change the display names.
I’ve found only one working way: add a field override using regexp. All works, but I can’t use groups in regexp. I want to do something like:
My_own_metric_(.+_.+) -> $1
I’ve tried a lot of different way to write it: $1, \1, ${“\1”},..
But I was only able to change it on static text.
I’m using Grafana-8.3.3-Ubuntu version.
Maybe someone knows a solution?
Apparently it's not possible to use groups in field override.
What you need to do is add an "operation" in the query itself:
+ Operations > Functions > Label replace
and set the legend:
Options > Legend > Custom > {{yourlabel}}.
So, an example for a straightforward mqtt exporter query,
changing the displayed label
from $SYS/broker/clients/maximum
to maximum:

How to change default filter search clause in service now platform?

When we make a search for users or incidents the default search clause is "greater than or is" but i want to change it to "is" clause.
Can anyone tell me how to do that?
The property #Antonio mentioned is the only way to affect the default search behavior, but if you prefix your search term with an equals sign, it will do an exact match.
e.g. You want to search for London in the city field, just type =london in the search bar and you'll get an exact match.
You can also prefix with * for contains or prefix/suffix with % for a startswith/endswith.
There does not seem to be an option to do this. However, you can change the default search behavior to "contains" by creating a boolean property named glide.ui.goto_use_contains in your system properties.
More info on this here

To find whether annotation type is part of the covered text

Sample Input file:
<p class="Head1"><a name="para1">Sections 87-89</a></p>
some text
<p class="Head2"><a name="para2">Sections 90-92</a></p>
some text
<p class="ParaFL"><a name="para3">Some Text1</a></p>
<p class="ParaFirstLineInd"><a name="para4">Some Text2</a></p>
For example from the sample input file, if I annotate "Sections 87-89 and Sections 90-92" as Head1".Now I want to compare the annotation type(Head1) with its class type ( class="Head1", class="Head").If annotation type is not equal to class, then I want to set a feature "class changed" for the corresponding annotation type.Similarly for "Some Text1" and "Some Text2" is annotated as ParaFL(annotation type).
It depends on how the required information is represented. I assume that the class information is represented by the HtmlTypeSystem in Ruta.
There are two language elements missing in Ruta (2.4.0) in order to solve this. The main problem is that the attribute information of html tag is stored in two separate arrays and there is not option in Ruta to jointly iterate over them. the second on is autoboxing of types to strings.
I recommend to create an analysis engine (which can also be executed from within a Ruta script), which creates new annotations with one string feature containing the required information. Then, you can compare the annotation to the feature value. Autoboxing does not convert the short type names. I would add a feature to your annotations types with the corresponding type/class values. Then, you can compare the feature values.

Using covered text on an annotator in UIMA RUTA

I would like to use the covered text of an annotation as in input in the subsequent code (eg, to name another annotation). Is it possible to recall the covered text and mention it again in the code? For example, if I have the following text -
Heading1
.............(Text 1)
Heading2
..............(Text 2)
Code:
DECLARE Header
"Heading1" {-> MARK(Header)}
DECLARE Text_Heading1 (where Heading1 = covered text of header)
Is it possible to do this in Ruta?
Thanks a lot!
DECLARE Header;
DECLARE TextHeading (STRING headerText);
"Heading." -> Header;
Header{-> TextHeading, TextHeading.headerText=Header.ct};
"ct" refers to the covered text of the matched annotation as a feature. If the annotations should be created at different positions, you may need to use additional language elements like a string variable, MATCHEDTEXT, and CREATE/GATHER or label expressions.

referencing issue with rule that has multiple elements matching the same annotation type

This little problem has kept me up for a couple of nights now.
I have the following UIMA Ruta script:
(Action.type=="info_req"{->CREATE(CompAction,"type"=Action.type)}
Preposition? Article? ServiceItem{->FILL(CompAction,"target"=ServiceItem, "num_targets"=1),SHIFT(CompAction,1,4)}
(Preposition? Article? ServiceItem)?{
->FILL(CompAction, "target2"=ServiceItem, "num_targets"=2, "selection"="OR") })
{->SHIFT(CompAction,1,1)}
;
It is supposed to match the following sentence:
I want information about the card about the gold credit card
Annotation Action matches "I want information"
Annotation Preposition matches "about"
Annotation Article matches "the"
Annotation ServiceItem matches "card" and "gold credit card"
The desired result should be a CompAction Annotation with the following features:
Feature target: (type ServiceItem) card
Feature target2: (type ServiceItem) gold credit card
Unfortunately, the result I get is:
Feature target: (type ServiceItem) card
Feature target2: (type ServiceItem) card
i.e. I get the same ServiceItem twice, which seems to be a referencing problem, unless I am doing something very wrong.
For UIMA Ruta 2.1.0: The FILL action considers the complete rule match for the values of the features and, thus, the second FILL action also selects the first suitable annotation. A solution for this problem could be to use different types (subtypes) for the different ServiceItem annotations in order to distinguish them.
For UIMA Ruta 2.2.0: The functionality is implemented and is already available in the current trunk. The rule should do as desired.