Reputation: 13
I am new to using brat annotation tool and I want to convert two of my annotation files "test.ann" and "train.ann" to .json files so that I can use them in my neural network. Is there any specific conversion tool for the same? I have tried a cli tool but it's written in the GO language and I would like to know if there is any written in the Python language
Upvotes: 1
Views: 554
Reputation: 198496
I did write a little something, but primarily for myself, so it is not published on PyPI, or documented very well. The repo is here. I don't think the bratpy.json
module supports all of the possibilities, but if there is something you need that is missing, tell me and I'll try to work it in. However, it produces one specific format of JSON (compatible with brat visualisation input), and if you need something different, it would be better to use the low-level bratpy.annotation
module to parse brat files and implement the conversion yourself. bratpy.annotation
is actually the same code that we used in brat itself, so it fully implements brat format.
The usage of the bratpy.annotation
has some documentation at the top of the source file. bratpy.json
doesn't have any, but it should be easy to deduce looking at the source file — you will need to use the bratpy.annotation.TextAnnotationsWithText
object, and the configuration files loaded from bratpy.conf
.
Upvotes: 1