| Lingua-EN-Semtags-Engine documentation | Contained in the Lingua-EN-Semtags-Engine distribution. |
Lingua::EN::Semtags::Sentence - a DTO used by Lingua::EN::Semtags::Engine
use Lingua::EN::Semtags::Sentence;
A DTO used by Lingua::EN::Semtags::Engine. Aggregates instances of
Lingua::EN::Semtags::LangUnits.
Adds $lunit to $self->{lunits}.
Returns $self->{lunits}.
Returns $self->{phrase_tokens}. Returns a hash ref. The hash is of the
following format: {$phrase_token => 1}.
Returns/sets $self->{string}.
Returns $self->{word_tokens} (a hash ref). The hash is of the
following format: {$word_token => $pos}.
Igor Myroshnichenko <igorm@cpan.org>
Copyright (c) 2008, All Rights Reserved.
This software is free software and may be redistributed and/or modified under the same terms as Perl itself.
| Lingua-EN-Semtags-Engine documentation | Contained in the Lingua-EN-Semtags-Engine distribution. |
package Lingua::EN::Semtags::Sentence; use strict; use warnings; use constant TRUE => 1; use constant FALSE => 0; our $VERSION = '0.01'; #============================================================ sub new { #============================================================ my ($invocant, %args) = @_; my $self = bless ({}, ref $invocant || $invocant); $self->_init(%args); return $self; } #============================================================ sub _init { #============================================================ my ($self, %args) = @_; # Initialize attributes $self->{string} = undef; $self->{word_tokens} = {}; # $token => $pos $self->{phrase_tokens} = {}; # $token => TRUE $self->{lunits} = []; # Set the args that came from the constructor foreach my $arg (sort keys %args) { die "Unknown argument: $arg!" unless exists $self->{$arg}; $self->{$arg} = $args{$arg}; } } #============================================================ sub string { defined $_[1] ? $_[0]->{string} = $_[1] : $_[0]->{string}; } sub word_tokens { $_[0]->{word_tokens}; } sub phrase_tokens { $_[0]->{phrase_tokens}; } sub lunits { @{$_[0]->{lunits}}; } sub add_lunit { push @{$_[0]->{lunits}}, $_[1]; } #============================================================ TRUE; __END__