Constraints across layer

110 views
Skip to first unread message

Kyle Williams

unread,
May 25, 2021, 8:51:08 PM5/25/21
to inception-users

Hi there

I've been banging my head against a wall for the last few hours trying to get this to work. I assume I'm doing something wrong but I can't figure out what it is.

I have two layers:
1) EventTriggerLayer: type = span, features = {label: [String], arg: [Link: SdohEventArg]}. The label feature has a tagset with ["Employed", "Insurance", Housing"].
2) EventArgLayer: type = span, features = {label: [String], status_employed: [String]}. Both of these features have a tagset with several available options.

What I'm trying to do is annotate an EventTriggerLayer span, assign a "label" feature, and then add the "arg" feature. However, when adding the arg feature I only want it to show the status_employed feature if EventTriggerLayer.label == "Employed" and EventArgLayer.label == "status". I have checked "Hide when no constraints apply" on the status_employ feature.

I have set up my constrains file as follows:

import webanno.custom.EventArg as Event;
import webanno.custom.EventTrigger as Trigger;

Event {
  @Trigger.label="Employment" & label="status" -> status_employed="employed";
}

The problem is that I cannot get the status_employed feature to show. If I remove the @Trigger.label="Employment" part then it works just fine, but I can't seem to get it to work with a constrain on the Trigger layer.

Any help will be greatly appreciated!

Richard Eckart de Castilho

unread,
May 26, 2021, 2:43:14 AM5/26/21
to incepti...@googlegroups.com
Hi,

> On 26. May 2021, at 02:51, Kyle Williams <kylemark...@gmail.com> wrote:
> I've been banging my head against a wall for the last few hours trying to get this to work. I assume I'm doing something wrong but I can't figure out what it is.
>
> I have two layers:
> 1) EventTriggerLayer: type = span, features = {label: [String], arg: [Link: SdohEventArg]}. The label feature has a tagset with ["Employed", "Insurance", Housing"].
> 2) EventArgLayer: type = span, features = {label: [String], status_employed: [String]}. Both of these features have a tagset with several available options.
>
> What I'm trying to do is annotate an EventTriggerLayer span, assign a "label" feature, and then add the "arg" feature. However, when adding the arg feature I only want it to show the status_employed feature if EventTriggerLayer.label == "Employed" and EventArgLayer.label == "status". I have checked "Hide when no constraints apply" on the status_employ feature.

Without having tried this in the tool right now, the rule should probably look somewhat like this:

import webanno.custom.EventArg as Event;
import webanno.custom.EventTrigger as Trigger;

Event {
arg.target.label="Employment" & label="status" -> status_employed="employed";
}

What you are saying right now with "Event { @Trigger.label="Employment" ... -> }" is "if there is an annotation of type Trigger at the same location as the current Event annotation and the label feature of that trigger is 'Employment', then activate".

What you probably want to say with "arg.target.label="Employment"" is "if the current event has an argument where the argument has a feature label with value 'Employment', then activate".

As I said: didn't have time to try it yet, but I believe it should work.

Here is a related example from one of our tests:

```
import webanno.custom.ComplexLinkHost as HOST;

HOST {
links.target.value = "PER" & links.target.value = "LOC" -> value = "move";
links.target.value = "PER" & links.target.value = "ORG" -> value = "buy";
links.target.value = "ORG" & links.target.value = "ORG" -> value = "buy";
}
```


-- Richard

Kyle Williams

unread,
May 26, 2021, 1:03:33 PM5/26/21
to inception-users
Hi Richard

Thanks for the response.

On Tuesday, 25 May 2021 at 23:43:14 UTC-7 richard...@gmail.com wrote:

Without having tried this in the tool right now, the rule should probably look somewhat like this:

import webanno.custom.EventArg as Event;
import webanno.custom.EventTrigger as Trigger;

Event {
arg.target.label="Employment" & label="status" -> status_employed="employed";
}

I tried this and the message that I'm getting is:

Unable to evaluate constraints: IllegalStateException: Feature [arg] does not exist on type [webanno.custom.EventArg

So it seems that it is unable to find the arg feature on the current layer, which makes sense since it's actually part of the EventTrigger layer. I've tried playing around with the syntax, but haven't been able to change it in such a way that it works.

 
What you are saying right now with "Event { @Trigger.label="Employment" ... -> }" is "if there is an annotation of type Trigger at the same location as the current Event annotation and the label feature of that trigger is 'Employment', then activate".

What you probably want to say with "arg.target.label="Employment"" is "if the current event has an argument where the argument has a feature label with value 'Employment', then activate".

Is there documentation on this in the user manual? I couldn't find anything.

Thanks
Kyle

Richard Eckart de Castilho

unread,
May 26, 2021, 1:46:24 PM5/26/21
to incepti...@googlegroups.com
Hi,

> I tried this and the message that I'm getting is:
> Unable to evaluate constraints: IllegalStateException: Feature [arg] does not exist on type [webanno.custom.EventArg
>
> So it seems that it is unable to find the arg feature on the current layer, which makes sense since it's actually part of the EventTrigger layer. I've tried playing around with the syntax, but haven't been able to change it in such a way that it works.

Ah, yes - missed that.

> What you are saying right now with "Event { @Trigger.label="Employment" ... -> }" is "if there is an annotation of type Trigger at the same location as the current Event annotation and the label feature of that trigger is 'Employment', then activate".
>
> What you probably want to say with "arg.target.label="Employment"" is "if the current event has an argument where the argument has a feature label with value 'Employment', then activate".
>
> Is there documentation on this in the user manual? I couldn't find anything.

We have this: https://inception-project.github.io/releases/0.19.4/docs/user-guide.html#sect_constraints

But the documentation only contains examples that work with the "role" attribute of slot features, none that works
with the "target" feature.

There are additional sets of rules used by the tests: https://github.com/inception-project/inception/tree/master/inception/inception-constraints/src/test/resources/rules

Mind they are sometimes not really tidy. The example using the "target" feature that I had posted before is "slot_feature_in_condition.rules".

Maybe you could provide a screenshot of your layers in action with an annotation of the EventTriggerLayer selected in the right sidebar?

-- Richard

Kyle Williams

unread,
May 26, 2021, 3:22:16 PM5/26/21
to inception-users
Hi Richard

On Wednesday, 26 May 2021 at 10:46:24 UTC-7 richard...@gmail.com wrote:
Maybe you could provide a screenshot of your layers in action with an annotation of the EventTriggerLayer selected in the right sidebar?

Here are some screenshots - hopefully that helps. The variable/layer names are slightly different to my example.

My two layer configs:

EventTriggerLayer.PNG

EventArgLayer.PNG


This is annotating the event trigger. Once I select the employment label I then add the "Arg". Once I've selected the arg span I click on the blue bullseye next to it, leading to the next screenshot.


Annotation1.png

Here I am annotating the arg. I select status as the label and this is where I expect the "status_employ" feature to show up (called statusemployatt in the layer config).


Annotation2.png


Let me know if this is useful and if what I'm trying to do is possible.

Thanks!
Kyle

Richard Eckart de Castilho

unread,
May 26, 2021, 3:50:40 PM5/26/21
to incepti...@googlegroups.com
On 26. May 2021, at 21:22, Kyle Williams <kylemark...@gmail.com> wrote:
>
> Here are some screenshots - hopefully that helps. The variable/layer names are slightly different to my example.

So, the SdohEventTrigger has a link named "Arg" (mind capitalization!) to the SdohEventArg.
In terms of the constraints, that means that features on the SdohEventTrigger can be constraint by either information on the SdohEventTrigger or information on the SdohEventArg it refers to.

However, you cannot constrain features on the SdohEventArg based on information in the SdohEventTrigger because the SdohEventArg does not actually know that it is linked to the SdohEventTrigger. The "link" is directional from SdohEventTrigger to SdohEventArg and constraint rules cannot work in the reverse direction.

If asked how I would model the type of information you are looking at, I would suggest
something like (if you go without role labels)):

-----
"She had a full time job at the hospital."

EventArg [She] (label: person)

EventTrigger [had] (
arg: {target: EventArg[She]}, {target: EventArg[hospital]}
label: "employment status")

EventArg [hospital] (label: organization)
-----

And then define a constraint which says that the label "employment status" on the EventTrigger is induced by the argument labels "person" and "organization":

EventTrigger {
Arg.target.label = "person" & Arg.target.label = "organization" -> label = "employment status";
}

-- Richard

Kyle Williams

unread,
May 26, 2021, 4:00:06 PM5/26/21
to inception-users
On Wednesday, 26 May 2021 at 12:50:40 UTC-7 richard...@gmail.com wrote:
So, the SdohEventTrigger has a link named "Arg" (mind capitalization!) to the SdohEventArg.
In terms of the constraints, that means that features on the SdohEventTrigger can be constraint by either information on the SdohEventTrigger or information on the SdohEventArg it refers to.

However, you cannot constrain features on the SdohEventArg based on information in the SdohEventTrigger because the SdohEventArg does not actually know that it is linked to the SdohEventTrigger. The "link" is directional from SdohEventTrigger to SdohEventArg and constraint rules cannot work in the reverse direction.

Thanks Richard. It makes total sense now why it doesn't work the way I want it to.
 
If asked how I would model the type of information you are looking at, I would suggest
something like (if you go without role labels)):

-----
"She had a full time job at the hospital."

EventArg [She] (label: person)

EventTrigger [had] (
arg: {target: EventArg[She]}, {target: EventArg[hospital]}
label: "employment status")

EventArg [hospital] (label: organization)
-----

And then define a constraint which says that the label "employment status" on the EventTrigger is induced by the argument labels "person" and "organization":

EventTrigger {
Arg.target.label = "person" & Arg.target.label = "organization" -> label = "employment status";
}

If I'm understanding this correctly it seems like I would need to label "person" and "organization" first in order to trigger the constraint. Is this correct? If so it's the wrong way around since we want to label the Trigger first and then the arguments. Perhaps I misunderstand it?

It seems like roles may be worth looking into.

Kyle
 

Richard Eckart de Castilho

unread,
May 26, 2021, 4:06:00 PM5/26/21
to incepti...@googlegroups.com
On 26. May 2021, at 22:00, Kyle Williams <kylemark...@gmail.com> wrote:
>
> If I'm understanding this correctly it seems like I would need to label "person" and "organization" first in order to trigger the constraint. Is this correct? If so it's the wrong way around since we want to label the Trigger first and then the arguments. Perhaps I misunderstand it?
> It seems like roles may be worth looking into.

If you want the label of the event trigger to determine what the args can be, then you would
define constraints on the label feature of the EventTrigger which would control the default
slots of the trigger. There are examples for this in the documentation - look for rules
which include a `(!)` behind the rule actions, e.g.

EventTrigger {
label = "Employment status" -> Args.role = "employee" (!) | Args.role = "employer" (!);
}

Cheers,

-- Richard

Kyle Williams

unread,
May 26, 2021, 4:10:01 PM5/26/21
to inception-users
Thanks for all of your help Richard. I'll spend some time looking into this.

Kyle Williams

unread,
May 28, 2021, 2:28:51 AM5/28/21
to inception-users
Hi Richard

Follow up question. I've been playing around with the Frame example and the use of SemPred and SemArg. I have my own layer that has a link feature "args" with type SemArg. I have another feature called "label" with type SemArg. I have enabled roles for both features and specified the tagsets.

However, in the annotation UI it only shows arcs for one of the link features (args). I have double and triple checked and can't find any difference between the features. My expectation is that it would show arcs for both link features. I have attached screenshots below showing the configuration of each feature as well as the UI when annotating the features.

link1.png

link2.png
ui.png

Any idea what I'm missing?

Thanks
Kyle

Richard Eckart de Castilho

unread,
May 28, 2021, 2:36:26 AM5/28/21
to incepti...@googlegroups.com
Hi Kyle,

> On 28. May 2021, at 08:28, Kyle Williams <kylemark...@gmail.com> wrote:
>
> Follow up question. I've been playing around with the Frame example and the use of SemPred and SemArg. I have my own layer that has a link feature "args" with type SemArg. I have another feature called "label" with type SemArg. I have enabled roles for both features and specified the tagsets.
>
> However, in the annotation UI it only shows arcs for one of the link features (args). I have double and triple checked and can't find any difference between the features. My expectation is that it would show arcs for both link features. I have attached screenshots below showing the configuration of each feature as well as the UI when annotating the features.

that sounds like a bug to me. It shouldn't make a difference if you have one or ten link features - they should all render their args.

It would be great if you could help by putting your explanation and images into a bug report so we can track it more easily.

If you could attach a minimal project export illustrating the problem, would be even better.

https://github.com/inception-project/inception/issues/new?template=bug_report.md

From a usability/practicality point of view, I would imagine though that a single link feature
should be sufficient for most cases and distinctions could as well be represented in the role label.

Best,

-- Richard

Kyle Williams

unread,
May 28, 2021, 2:44:21 AM5/28/21
to inception-users
Hi Richard

On Thursday, 27 May 2021 at 23:36:26 UTC-7 richard...@gmail.com wrote:
that sounds like a bug to me. It shouldn't make a difference if you have one or ten link features - they should all render their args.

It would be great if you could help by putting your explanation and images into a bug report so we can track it more easily.

If you could attach a minimal project export illustrating the problem, would be even better.

https://github.com/inception-project/inception/issues/new?template=bug_report.md

Sure, I'll file a bug report. It's getting late so I will likely do it in the morning.

From a usability/practicality point of view, I would imagine though that a single link feature
should be sufficient for most cases and distinctions could as well be represented in the role label.

The example that I showed above was just a simple case because I was trying to figure out why I wasn't getting arcs for both features.

My use case is a little bit more complicated. I have one feature for which roles work fine. But then I also have other links that I want to capture where I want to select a span and then choose from a tagset. My understanding is that roles are not the right approach for this. So the way I've been doing it is to have one feature with roles, and then have another feature with a link to a layer that has its own feature with a tagset.

Kyle Williams

unread,
May 28, 2021, 2:48:08 AM5/28/21
to inception-users
On Thursday, 27 May 2021 at 23:44:21 UTC-7 Kyle Williams wrote:
Hi Richard

On Thursday, 27 May 2021 at 23:36:26 UTC-7 richard...@gmail.com wrote:
that sounds like a bug to me. It shouldn't make a difference if you have one or ten link features - they should all render their args.

It would be great if you could help by putting your explanation and images into a bug report so we can track it more easily.

If you could attach a minimal project export illustrating the problem, would be even better.

https://github.com/inception-project/inception/issues/new?template=bug_report.md

Sure, I'll file a bug report. It's getting late so I will likely do it in the morning.

I have no idea what happened, but I opened the annotation UI in Firefox and it showed all links. I then went back to Edge (which I was using before) and the links show now.

I guess that means it's working as expected, but it seems there may be some weird browser issues going on. I will try to reproduce it.

Richard Eckart de Castilho

unread,
May 28, 2021, 2:50:43 AM5/28/21
to inception-users
On 28. May 2021, at 08:48, Kyle Williams <kylemark...@gmail.com> wrote:
>
> I have no idea what happened, but I opened the annotation UI in Firefox and it showed all links. I then went back to Edge (which I was using before) and the links show now.
>
> I guess that means it's working as expected, but it seems there may be some weird browser issues going on. I will try to reproduce it

Which version are you using?

If you use a version prior to 0.19.4, maybe you hit this bug:

https://github.com/inception-project/inception/issues/2223

-- Richard

Kyle Williams

unread,
May 28, 2021, 2:53:39 AM5/28/21
to inception-users
Ah, I'm using 0.19.1.

I will ask our admin to update it tomorrow and then report back.

Thanks

Kyle Williams

unread,
Jun 1, 2021, 4:04:16 PM6/1/21
to incepti...@googlegroups.com
Just closing the loop - this indeed was fixed by upgrading to 0.19.4.

--
You received this message because you are subscribed to a topic in the Google Groups "inception-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/inception-users/HExNHKgsrwo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to inception-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/inception-users/b5d89a6a-60f2-4678-a96e-bda2b5378fcdn%40googlegroups.com.
--
Reply all
Reply to author
Forward
0 new messages