JohnGiorgi / seq2rel-ds

This is a companion repository to seq2rel (https://github.com/JohnGiorgi/seq2rel) which aims to make it easy to generate training data.
5 stars 1 forks source link

Add entity hinting #23

Closed JohnGiorgi closed 3 years ago

JohnGiorgi commented 3 years ago

This PR adds "entity hinting", which is basically the ability to insert hints as to the location and type of entities within the source text. For example, in the following text we provide hints for two entities, a chemical and a disease, that are involved in a "chemical-induced disease" relationship:

We describe a 42-year-old woman who developed superior @START_DISEASE@ sagittal and left transverse sinus thrombosis @END_DISEASE@ associated with prolonged @START_CHEMICAL@ epsilon-aminocaproic acid @END_CHEMICAL@.

The purpose of this is so that we can compare to document-level relation extraction techniques that are not joint. I made a couple of decisions here:

  1. Only provide hints for the first (unique) occurrence of an entity.
  2. Only provide hints for entities involved in a relation.

both of these decisions help limit the amount of additional tokens introduced in the source text.

This functionality is also exposed by the bc5cdr and gda commands with the flag --include-ent-hints. I have not added them for the other commands, because the entity hinting code only works for PubTator formatted text. In the future, I will update all commands to first convert their datasets to the PubTator format, so that we can standardize parsing and postprocessing. Tracking that in #24.

Finally, for whatever reason, adding an option to the main callback broke things, and so now it has to be a command and therefore invoked with seq2rel-ds preprocess <command> main. I am tracking this in #25.