Lingua::EN::Semtags::Sentence - a DTO used by C<Lingua::EN::Semtags::Engine>


Lingua-EN-Semtags-Engine documentation Contained in the Lingua-EN-Semtags-Engine distribution.

Index


Code Index:

NAME

Top

Lingua::EN::Semtags::Sentence - a DTO used by Lingua::EN::Semtags::Engine

SYNOPSIS

Top

  use Lingua::EN::Semtags::Sentence;

DESCRIPTION

Top

A DTO used by Lingua::EN::Semtags::Engine. Aggregates instances of Lingua::EN::Semtags::LangUnits.

METHODS

add_lunit($lunit)

Adds $lunit to $self->{lunits}.

lunits()

Returns $self->{lunits}.

phrase_tokens()

Returns $self->{phrase_tokens}. Returns a hash ref. The hash is of the following format: {$phrase_token => 1}.

string([$string])

Returns/sets $self->{string}.

word_tokens()

Returns $self->{word_tokens} (a hash ref). The hash is of the following format: {$word_token => $pos}.

SEE ALSO

Top

Lingua::EN::Semtags::Engine

AUTHOR

Top

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__