How to implement brat automatic annotation?

1,535 views
Skip to first unread message

Victoria Stuart

unread,
Jan 30, 2015, 5:25:14 PM1/30/15
to brat-...@googlegroups.com
Fri Jan 30, 2015

Hello! I an a novice brat user:  I wish to annotate (and/or tag) a set of cancer-related documents, for (i) machine learning { training | test sets }, as well as for evaluating a biomedical NLP parser.

While I anticipate creating some custom (cancer) annotations specific to our research needs, I think that it would be enormously helpful to be able to pre-annotate those documents according to well-established standards (Like CRAFT or BioCreative).

In exploring the tool (brat), I figured out that if I tweak the [annotators] subsection in tools.conf, I can get some things to display here:

brat Menu >> Data >> Automatic annotation

... however, I was only able to find / get working ONE such external API (below).

Q1. List of online annotation services (APIs)?

 ** this works:

Cocoa_NER tool:Cocoa, model:NER, <URL>:http://npjoint.com/Cocoa/bratapi/


Are there any others, PARTICULARLY relating to the biomedical / cancer literature (CRAFT; GENIA; ...)?

Even better, s there a way to do this (automatically or even manually), selecting from the configurations provided in the 'configurations' folder?

----------

Also, I presume that I am correct, regarding the following?

Q2. How to SAVE an applied annotation?

 ** automatically saved in related .ann file

Q3. How to UNDO an applied annotation?

 ** delete the (contents, NOT the file) of the related .ann file

Thank you!

Victoria :-)

Ben Olayinka

unread,
Oct 14, 2017, 8:53:36 AM10/14/17
to brat-users
I came across this thread while I was searching for something similar, and I ended up writing my own tool to hook spaCy up to brat for automatic annotation. There are examples to configure any annotation service you like, in brat/tools/

I've attached the spaCy tagger service script. You should just need spaCy installed via pip for it to work.

For anyone whose interested in the technical details, the brat automatic annotation feature works by querying a server with your text, and then looking for a json object to be returned containing the annotations in standoff format. The python script creates an HTTP handler (by default on port 47111, see script to change it) which brat can communicate with for annotations. It's been very useful for us, for speeding up annotations and also for visualising the results of our training.

To use the script, just leave it running, and it will keep the HTTP server alive to handle requests, with some diagnostics if you encounter any errors.

Also add this to your tools.conf, and then access it via data - automatic annotation:

[annotators]
spaCy tool:spaCy, model:spaCy, <URL>:http://localhost:47111 
spacynlptagger.py

Gmosy Gnaq

unread,
Nov 25, 2017, 5:58:52 AM11/25/17
to brat-users
It worked for me! Thanks a lot!

Ben Olayinka

unread,
Nov 29, 2017, 6:50:09 AM11/29/17
to brat-users
Cool, I'm glad. There's a little bug I remember, though. If spaCy returns a tag that contains a newline, it breaks the brat annotation file. You can poke through the tagger service and drop newlines, as a temporary fix. The better fix which may not ever come, is for Brat to properly escape text in standoff files.
Reply all
Reply to author
Forward
0 new messages