Package: bratiaa
bratiaaInter-annotator agreement forBratannotation projects. For a quick overview of the output generated bybratiaa, have a look at theexample files. So far only text-bound annotations are supported, all other annotation types are ignored. This package is an improved version of the code for calculating inter-annotator agreement used byKolditz et al. (2019).InstallationInstall the package via pip.pipinstallbratiaaProject StructureBy defaultbratiaaexpects that each first-level subdirectory of the annotation project contains the files of one annotator. It will automatically determine the set of files annotated by each annotator (files with the same relative path starting from the different annotators' directories). Here is a simple example:example-project/
├──annotation.conf
├──annotator-1
│├──doc-1.ann
│├──doc-1.txt
│├──doc-3.ann
│├──doc-3.txt
│└──second
│├──doc-2.ann
│└──doc-2.txt
└──annotator-2├──doc-3.ann├──doc-3.txt├──doc-4.ann├──doc-4.txt└──second├──doc-2.ann└──doc-2.txtIn this example, we have two agreement documents: 'second/doc-2.txt' and 'doc-3.txt'. The other two documents are only annotated by a single annotator.If you have a different project setup, you need to provide your owninput_generatorfunction, yielding document objects with paths to the plain text and all corresponding ANN files (cf.bratiaa.agree.py).UsageYou can either usebratiaaas a Python library or as a command-line tool.Python Interfaceimportbratiaaasbiaaproject='/path/to/brat/project'# instance-level agreementf1_agreement=biaa.compute_f1_agreement(project)# print agreement report to stdoutbiaa.iaa_report(f1_agreement)# agreement per labellabel_mean,label_sd=f1_agreement.mean_sd_per_label()# agreement per documentdoc_mean,doc_sd=f1_agreement.mean_sd_per_document()# total agreementtotal_mean,total_sd=f1_agreement.mean_sd_total()For the token-level evaluation, please use your own tokenization function. This function should yield (start, end) offset tuples for any given string like the example function below.importreimportbratiaaasbiaadeftoken_func(text):token=re.compile('\w+|[^\w\s]+')formatchinre.finditer(token,text):yieldmatch.start(),match.end()# token-level agreementf1_agreement=biaa.compute_f1_agreement('/path/to/brat/project',token_func=token_func)CLIHelp message:brat-iaa -h# instance-level agreement and heatmapbrat-iaa/path/to/brat/project--heatmapinstance-heatmap.png>instance-agreement.md# token-level agreement (not recommended)brat-iaa/path/to/brat/project-t--heatmaptoken-heatmap.png>token-agreement.mdThe token-based evaluation of the command-line interface uses the generic pattern'\S+'to identify tokens (splitting on whitespace) and hence is not recommended. Please use the Python interface with a language- and task-specific  tokenizer instead.For the output formats generated by the above commands, have a look at theexample files.Agreement MeasureWe can think of an annotation as a triple(d, l, o), wheredis a document id,la label, andois a list of start-end character offset tuples. An annotatoricontributes a (multi)setAiof (token) annotations. We computeF1ij= 2 | Ai∩ Aj| / (|Ai| + |Aj|)for each 2-combination of annotators and report arithmetic mean and standard deviation ofF1across all these combinations (seeHripcsak & Rothschild, 2005). Grouping annotations by documents or labels allows us to calculateF1per document or label.Instance-Based AgreementEach text-bound annotation in Brat is an annotation instance. Two identical instances from a single annotator (a triple whered,l, andoare identical) are considered as accidental - only unqiue annotation instances are used for calculating agreement, i.e., we are dealing with sets.Token-Based AgreementEach annotation instance is split up into its overlapping tokens, e.g. if our tokenizer splits on whitespace, "[ORGHuman Rights Watch]" and "[ORGHuman Rights Wat]ch" both become "[ORGHuman] [ORGRights] [ORGWatch]". We are dealing with multisets of these split annotations, allowing for multiple token-based annotations on the same document, with the same label and offsets in the case of overlapping annotations of the same type. For example, in "[LOCUniversity of [LOCJena]]" we have two overlapping location annotations resulting in four token-based annotations of which two are identical ("[LOCJena]").Be aware that "[ORGHuman] [ORGRights Watch]" and "[ORGHuman Rights] [ORGWatch]" both become "[ORGHuman] [ORGRights] [ORGWatch]", that is, boundary errors between adjacent annotations of the same type are ignored!ReferencesHripcsak, G., & Rothschild, A. S. (2005).Agreement, the f-measure, and reliability in information retrieval. Journal of the American Medical Informatics Association, 12(3), pp. 296-298.Kolditz, T., Lohr, C., Hellrich, J., Modersohn, L., Betz, B., Kiehntopf, M., & Hahn, U. (2019).Annotating German clinical documents for de-identification. In MedInfo 2019 – Proceedings of the 17th World Congress on Medical and Health Informatics. Lyon, France, 25-30 August 2019. IOS Press, pp. 203-207.LicenseThis software is provided under theMIT-License. The code contains a modified subset of brat, which is available under the same permissivelicense.