Problem reading custom annotation with features that reference other annotations

8 views
Skip to first unread message

Alain Désilets

unread,
Dec 5, 2019, 5:24:29 PM12/5/19
to dkpro-core-user
I am trying to create an annotation type called 'CasualtiesRelationNary'. This is meant to capture relations of the form:

CARDINAL people-died-of DISEASE at-location LOC and-at-time (DATE|TIME)

I have defined an annotation by that name in my UIMA type descriptor file, which has the following attributes, all of which are Annotations
  • location: Annotation that identifies the location of the deatns
  • numDeaths: Annotation that provides the number of deaths
  • time: Annotation that provides the time of the deaths
  • disease: Annotation that provides the location where the deaths took place
I have written a pipeline that is able to tag sentences that define such relations. The pipeline is able to write the results to Brat files.

But when I try to read the Brat files, I get the following exception:

Type [ca.nrc.t2rels.freetext.annotations.CasualtiesRelationNary] has no feature called [value]

Attached is a Maven project that illustrates the problem. You will get the above exception if you run the 'ReadFileWithCasualtiesRelation' app, passing it the full path of the src/main/resources/testfiles/west-nile.txt file.

The file was produced by the casualties annotation pipeline.

Note that the app uses a class BratUtils. This is a help class I wrote to circumvent various brittleness problems with the BratReader and BratWriter classes. I think a lot of those solutions could be wrapped into BratReader and BratWriter, but that is a different conversation that I will start in a different post some time.

NaryRelationProblem.tar.gz

Richard Eckart de Castilho

unread,
Dec 6, 2019, 3:04:18 AM12/6/19
to dkpro-c...@googlegroups.com
Hi Alain,

thanks for the example. I have attached a minimal set of files which I changed/added to this mail.

* upgraded to DKPro Core 1.12.0
* moved the mapping into a JSON file
* set up a minimal pipeline example "Example.java"

Note how the example works with the readers and writers in Example.java
without the need for the JCasCapturer.

Cheers,

-- Richard

Example.java
mapping.json
pom.xml

Richard Eckart de Castilho

unread,
Dec 6, 2019, 6:41:02 AM12/6/19
to dkpro-core-user
Hi again,

I noticed from your code that you wanted to work with a catch-all type in the end.
So attached is a mapping which does that, although I used "dkpro...NamedEntity" instead
of "dkpro...Tag" since that seemed more reasonable to me. If that doesn't work for you,
I'd recommend you define a custom type as the catch-all.

Tag is a generally unused type from the syntax module which was used at some point when
processing parse trees with TRegex - but I think most of the code was never actually
included in DKPro Core. The type is no longer included with DKPro Core 2.x either.

The example code now also prints the named entities that were read.

Note that in the mapping file, the brat type "ca-nrc-t2rels-freetext-annotations-CasualtiesRelationNary"
is written as "ca.nrc.t2rels.freetext.annotations.CasualtiesRelationNary". The dots here are actually
regex-dots (i.e. match arbitrary individual characters), but in particular they match the "." character.
Before the brat type is processed internally, the dashes ("-") in the name are replaced by dots (".").
That is why a mapping

{
'from': 'ca-nrc-t2rels-freetext-annotations-CasualtiesRelationNary',
'to': 'ca.nrc.t2rels.freetext.annotations.CasualtiesRelationNary'
},

never matches.

Also note that this mapping comes before the catch-all in the mappings file.

Cheers,

-- Richard


Example.java
mapping.json

Richard Eckart de Castilho

unread,
Dec 6, 2019, 1:06:34 PM12/6/19
to dkpro-core-user
I have started writing some proper documentation for the BratReader. You might find it interesting. Let me know if you have any comments:

This is a reasonably readable rendering of the documentation

Here is the PR for leaving comments:

https://github.com/dkpro/dkpro-core/pull/1442

See the "Files changed" tab. If you click there on the tree dots next on the right of the file header and choose "view file", you can also access a half-reasonably rendered version of the file.

Cheers,

-- Richard

Alain Désilets

unread,
Dec 10, 2019, 1:58:35 PM12/10/19
to dkpro-core-user
Thx. The changes you illusted in Example.java did the trick. 
Reply all
Reply to author
Forward
0 new messages