Lingua-FreeLing3
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Lingua/FreeLing3/Word/Analysis.pm view on Meta::CPAN
package Lingua::FreeLing3::Word::Analysis;
use utf8;
use warnings;
use strict;
use Lingua::FreeLing3;
use Lingua::FreeLing3::Bindings;
use Lingua::FreeLing3::Word;
use Carp;
use parent -norequire, 'Lingua::FreeLing3::Bindings::analysis';
our $VERSION = '0.02';
=encoding UTF-8
=head1 NAME
Lingua::FreeLing3::Word::Analysis - Interface to FreeLing3 Analysis object
=head1 SYNOPSIS
use Lingua::FreeLing3::Word::Analysis;
# obtain the list of analysis
my $list_of_analysis = $word->analysis;
# create empty analysis object
my $analysis = Lingua::FreeLing3::Analysis->new();
my $data = $analysis->as_hash;
=head1 DESCRIPTION
This module interfaces to the Analysis object from FreeLing3. Usually
you do not need to create this kind of object, unless you are hacking
deep in the FreeLing3 library. The usual usage is to retrieve a list of
possible analysis for a specific word using the C<analysis> method on
L<Lingua::FreeLing3::Word> objects.
=head2 CONSTRUCTOR
=over 4
=item C<new>
At the present moment there is one only (empty) constructor. Returns
an C<Lingua::FreeLing3::Word::Analysis> object.
=back
=cut
sub new {
my $class = shift;
my $self = $class->SUPER::new();
return bless $self => $class #amen
}
sub _new_from_binding {
my ($class, $analysis) = @_;
return bless $analysis => $class #amen
}
=head2 ACESSORS
These methods let you query an Analysis object:
=over 4
=item C<as_hash>
Retrieve a reference to a hash that includes the analysis lemma,
tag (POS) and probability.
=back
=cut
sub as_hash {
my $self = shift;
my $prob = $self->prob;
return +{
lemma => $self->lemma,
tag => $self->tag,
defined($prob) ? (prob => $prob): ()
};
}
=head2 ACESSORS/SETTER
These methods let you access an object information or, if you pass any
argument to the method, set that information.
=over 4
=item C<lemma>
Query the current analysis lemma. Supply a string to the method to set
the analysis lemma.
my $lemma = $analysis->lemma;
=cut
sub lemma {
my $self = shift;
if ($_[0]) {
$self->SUPER::set_lemma(@_);
} else {
my $l = $self->SUPER::get_lemma;
utf8::decode($l);
return $l;
}
}
=item C<tag>
Query the current analysis tag (POS). Supply a string to the method
to set the analysis tag.
my $pos = $analysis->tag;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.498 second using v1.00-cache-2.02-grep-82fe00e-cpan-3b7f77b76a6c )