AI-CBR
view release on metacpan or search on metacpan
lib/AI/CBR/Case.pm view on Meta::CPAN
sub new {
my ($class, %attributes) = @_;
# set default weights if unspecified
foreach (keys %attributes) {
$attributes{$_}->{weight} = $DEFAULT_WEIGHT unless defined $attributes{$_}->{weight};
}
my $self = \%attributes;
bless $self, $class;
return $self;
}
=head2 set_values
Pass a hash of attribute keys and values.
This will overwrite existing values, and can thus be used as a faster method
for generating new cases with the same specification.
lib/AI/CBR/Case/Compound.pm view on Meta::CPAN
my ($class, @definitions) = @_;
# set default weights if unspecified
foreach my $attributes (@definitions) {
foreach (keys %$attributes) {
$attributes->{$_}->{weight} = $DEFAULT_WEIGHT unless defined $attributes->{$_}->{weight};
}
}
my $self = \@definitions;
bless $self, $class;
return $self;
}
=head2 set_values
Pass a flat hash of attribute keys and values.
This will overwrite existing values, and can thus be used as a faster method
for generating new cases with the same specification.
Notice that keys in the different specifications of the compound object may not have the same name!
lib/AI/CBR/Retrieval.pm view on Meta::CPAN
sub new {
my ($classname, $spec, $candidates) = @_;
croak('new case without candidates') unless @$candidates;
my $self = {
candidates => $candidates,
# we accept single specs as hash-ref or composed specs as array-ref
# internally both will be handled as a composed array-ref
queries => ref $spec eq 'AI::CBR::Case' ? [$spec] : $spec,
};
bless $self, $classname;
return $self;
}
=head2 compute_sims
If the case-specification is complete,
you may call this method to compute the similarities
of all candidate cases to this specification.
After this step, each candidate of the case-base will have an
( run in 2.002 seconds using v1.01-cache-2.11-cpan-4505f990765 )