NAME
NLP::GATE::Annotation - A class for representing GATE-like annotations
VERSION
Version 0.6
SYNOPSIS
use NLP::GATE::Annotation;
my $ann = NLP::GATE::Annotation->new($type,$fromOffset,$toOffset);
my $copy = $ann->clone();
$ann->setFromTo($fromOffset,$toOffset);
$ann->setType($type);
$ann->setFeature($name,$value);
$ann->setFeatureType($name,$type);
$value = $ann->getFeature($name);
$type = $ann->getFeatureType($name);
$from = $ann->getFrom();
$to = $ann->getTo();
DESCRIPTION
This is a simple class representing a GATE-like annotation for document text. The annotation knows about the text offsets from start (first character has offset 0) to end (the offset of the byte following the annotation). Zero length annotations should be avoided as gate cannot handle them properly.
All functions that set values return the original annotation object.
This library does not attempt to mirror the Java API or the way how annotations are represented and handled in the original GATE API.
A major difference to the GATE API is that annotations can live completely independent from annotation sets or documents and have their own constructor. An annotation is simply a range that is assiciated with a type and a map of features.
Another difference to the GATE API is that feature maps are NOT seperately modeled.
METHODS
new()
Create a new annotation.
clone()
Create a deep copy of an annotation, creating a new annotation object that has the same values as the old one, but contains no references to data contained in the old one.
setType($type)
Set a new annotation type. Must be a string and a valid type name.
getType()
Return the current annotation type.
setFromTo($fromOffset,$toOffset)
Set the text range of the annotation.
setFeature($name,$value)
Add or replace the feature of the given name with the new value.
setFeatureType($name,$type)
Add or replace the Java type associated with the feature. If this method is never used, the default for a feature is java.lang.String.
getFeatureType($name)
Return the Java type associated with the feature. If the type was never set, "java.lang.String" is returned. If no value is set for the feature, undef is returned.
getFeatureNames()
Return an array of feature names for this annotation. The order of feature names in the array is random and may change between successive calls.
setFeatures($hashref)
Add or replace all the features with the keys in the hash reference with the corresponding values in the hash reference.
getFeature($name)
Returns the value of the feature.
getFrom()
Returns the from offset.
getTo()
Returns the to offset.
AUTHOR
Johann Petrak, <firstname.lastname-at-jpetrak-dot-com>
BUGS
Please report any bugs or feature requests to bug-gate-document at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=NLP::GATE. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc NLP::GATE
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
RT: CPAN's request tracker
Search CPAN