Algorithm-Viterbi
view release on metacpan or search on metacpan
[ 'work', 'rainy' ],
];
my $v = Algorithm::Viterbi->new(start_state => '###');
$v->train($observations);
print Dumper($v);
will produce:
$VAR1 = bless( {
'transition' => {
'sunny' => {
'sunny' => '0.5',
'rainy' => '0.25'
},
'rainy' => {
'sunny' => '0.5',
'rainy' => '0.5'
},
'###' => {
lib/Algorithm/Viterbi.pm view on Meta::CPAN
The values of the attributes in the example are the default values.
For a detailed description and use of these attributes, see below.
=cut
sub new
{
my $class = shift;
my $self = {@_};
bless $self, $class;
$self->{unknown_transition_prob} = 0 if (!defined($self->{unknown_transition_prob}));
$self->{start_state} = '$' if (!defined($self->{start_state}));
return $self;
}
=item train
This method computes the start, emission and transition probabilities
lib/Algorithm/Viterbi.pm view on Meta::CPAN
[ 'work', 'rainy' ],
];
my $v = Algorithm::Viterbi->new(start_state => '###');
$v->train($observations);
print Dumper($v);
will produce:
$VAR1 = bless( {
'transition' => {
'sunny' => {
'sunny' => '0.5',
'rainy' => '0.25'
},
'rainy' => {
'sunny' => '0.5',
'rainy' => '0.5'
},
'###' => {
( run in 1.084 second using v1.01-cache-2.11-cpan-de7293f3b23 )