Brat::Handler::File - Perl extension for handling a Brat file
use Brat::Handler::File;
$bratFile = Brat::Handler::File->new($filename);
$bratFile->print("-");
The module handles Brat annotations associated to a text file. It also manages annotations concatenated from several files.
As for the annotations, the terms are stored in the attribute terms, relations in the attribute relations and attributes in the attribute attributes.
terms
relations
attributes
The name of the file containing the annotation is stored in the attribute annotationFilemane, and the name of the text file is recorded in the attribute textFilename. Since those attributes are arrays, it is possible to store annotations from several files.
annotationFilemane
textFilename
Other attributes are used to describe the annotations: maxTermId contains the last term id, maxRelationId contains the last relation id, maxAttributeId contains the last attribute id, and textSize records the number of characters of the text file.
maxTermId
maxRelationId
maxAttributeId
textSize
Brat::Handler::File::new($filename);
The method creates a Brat::Handler::File object and returns the object.
Brat::Handler::File
The filename can have the txt or the ann extension. $filename can be a string or a list of string. If $filename is specified and if it is a string, Brat annotations are loaded.
txt
ann
$filename
$bratFile->loadBratFile();
The method loads Brat annotation of the first file specified in the attribute annotationFilename.
annotationFilename
$bratFile->printStats($filename, $mode);
The method prints statistics on the loaded annotations.
$bratFile->getStats();
The method returns a string containing the statistics on the loaded annotations.
$bratFile->printTermList($filename, $mode);
The method prints a entity list in the Alvis::TermTagger format.
Alvis::TermTagger
$bratFile->getTermList();
The method returns a string containing the list of entities in the Alvis::TermTagger format.
$bratFile->getTerms();
The method returns an array containing the list of entities with their type.
$bratFile->printRelationList($filename, $mode);
The method prints relations between two entities with the type of the relation. Separator is : .
:
$bratFile->getRelationList();
The method returns a string containing the relations between two entities with the type of the relation. Separator is : .
$bratFile->getRelations();
The method returns an array containing the relations between two entities with the type of the relation.
$bratFile->getRelationTypes();
The method returns the reference to an hashtable containing the relations between two entities for each relation type. The relation types are the hash keys.
$bratFile->getTermTypes();
The method returns the reference to an hashtable containing the terms for each term type. The term types are the hash keys.
$bratFile->getAnnotationList();
The methods returns the annotations in the Brat format.
$bratFile->print($filename, $mode);
The methods prints the annotations in the Brat format.
http://brat.nlplab.org/
Thierry Hamon <hamon@limsi.fr>
Copyright (C) 2015 by Thierry Hamon
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
To install Brat::Handler, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Brat::Handler
CPAN shell
perl -MCPAN -e shell install Brat::Handler
For more information on module installation, please visit the detailed CPAN module installation guide.