The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Brat::Handler::File - Perl extension for handling a Brat file

SYNOPSIS

use Brat::Handler::File;

$bratFile = Brat::Handler::File->new($filename);

$bratFile->print("-");

DESCRIPTION

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.

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.

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.

METHODS

new()

    Brat::Handler::File::new($filename);

The method creates a Brat::Handler::File object and returns the object.

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.

loadBratFile()

    $bratFile->loadBratFile();

The method loads Brat annotation of the first file specified in the attribute annotationFilename.

printStats()

    $bratFile->printStats($filename, $mode);

The method prints statistics on the loaded annotations.

getStats()

    $bratFile->getStats();

The method returns a string containing the statistics on the loaded annotations.

printTermList()

    $bratFile->printTermList($filename, $mode);

The method prints a entity list in the Alvis::TermTagger format.

getTermList()

    $bratFile->getTermList();

The method returns a string containing the list of entities in the Alvis::TermTagger format.

getTerms()

    $bratFile->getTerms();

The method returns an array containing the list of entities with their type.

printRelationList()

    $bratFile->printRelationList($filename, $mode);

The method prints relations between two entities with the type of the relation. Separator is : .

getRelationList()

    $bratFile->getRelationList();

The method returns a string containing the relations between two entities with the type of the relation. Separator is : .

getRelations()

    $bratFile->getRelations();

The method returns an array containing the relations between two entities with the type of the relation.

getRelationTypes()

    $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.

getTermTypes()

    $bratFile->getTermTypes();

The method returns the reference to an hashtable containing the terms for each term type. The term types are the hash keys.

getAnnotationList()

    $bratFile->getAnnotationList();

The methods returns the annotations in the Brat format.

print()

    $bratFile->print($filename, $mode);

The methods prints the annotations in the Brat format.

SEE ALSO

http://brat.nlplab.org/

AUTHORS

Thierry Hamon <hamon@limsi.fr>

LICENSE

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.