The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

IDS::Algorithm - An IDS algorithm for use with IDS::Test

SYNOPSIS

A usage synopsis would go here. Since it is not here, read on.

DESCRIPTION

An IDS::Algorithm is a superclass for all of the IDS algorithms. This class was designed for HTTP requests, but should be usable in other areas. The idea here is to standardize the interface in such a way that it can be easily used by many algorithms.

The interface was designed for one-pass learning algorithms. Algorithms needing multiple passes can be made to work, but the interface is less clean. See "next_pass" in Methods.

When working with an IDS::Algorithm algorithm, the following operations exist:

new()

Create the object for the algorithm. If the parameters are supplied, they are used; otherwise everything is defaults (unsurprisingly). If a filehandle is supplied, the filehandle is taken as the source for a load operation.

The parameters affect how the algorithm operates. See the specific algorithm for most parameter information. General parameters are described below.

Parameters are simply entries in a hash (i.e., "name" => "value");

In most cases, this function can be used instead of the subclass version. Complex cases must duplicate the logic here.

save(filename)
save(filehandle)

Save the data in a form that will allow testing later. Some subclasses may save in a format that allows further addition as well. This is not required.

This version simply uses Data::Dumper; subclasses are likely to have better (and more efficient) designs.

load()
load(filename)
load(filehandle)

Load the data saved by save().

Note for subclasses: If no filename/filehandle is provided, use a default or command-line specified filename. The recommended commandline parameter is ids_state, tied to the parameter state_file.

This version simply uses Data::Dumper; subclasses are likely to have better (and more efficient) designs.

add(tokenref, string, n)

In training, this is an instance to learn. This function must be subclassed.

tokenref is a reference to a list of tokens, assuming the data source can produce tokens, an empty list otherwise.

string is the string version of the instance.

n is an object counter, which may be useful in output.

test(tokenref, string, n)

In testing, this is an instance to test. This function must be subclassed.

tokenref is a reference to a list of tokens, assuming the data source can produce tokens, an empty list otherwise.

string is the string version of the instance.

n is an object counter, which may be useful in output.

next_pass(tokenref, string, n)

For algorithms that require two passes over the training data, this function (if it exists) implements the next pass. Algorithms requiring more than two passes require that the algorithm remembers the training data itself.

initialize()

This (optional) function provides any subclass-specific initialization.

parameters()
parameters(param)
parameters(param, value, ...)

Set or retrieve the current parameters (individual or group).

Parameters

The following parameters are expected to be used (when the use makes sense) by all subclasses.

verbose

How much ``extra'' information to provide as we are working. 0 means nothing other than warnings and errors. Increasing values mean increasing output, but these details are left to the subclasses.

In order to avoid a name clash, the convention for the getopt name for the algorithm's verbose is algorithm_verbose, for example: ngram_verbose or dfa_verbose.

msg_fh

Where warning and error messages go; nowhere if undefined.

Additionally, subclasses may define their own parameters.

All subclasses must define all parameters to default values when new() is called. This is so the param_options can be properly handled.

param_options()

These are options definitions for Getopt::Long.

Utility functions

These may be useful for subclasses.

handle_parameters($self, @_)

Handle the parameter string that IDS::Algorithm::new() will accept. Extracted from new() for subclass usage. Returns a filehandle if we were called with a filehandle from which to load.

default_parameters()

Assign default values to all parameters.

find_fname(filename)

Return the supplied filename. If it is undefined or otherwise missing, fall back on using ${$self->{"params"}}{"state_file"}

AUTHOR INFORMATION

Copyright 2005-2007, Kenneth Ingham. All rights reserved.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Address bug reports and comments to: ids_test at i-pi.com. When sending bug reports, please provide the versions of IDS::Test.pm, IDS::Algorithm.pm, IDS::DataSource.pm, the version of Perl, and the name and version of the operating system you are using. Since Kenneth is a PhD student, the speed of the reponse depends on how the research is proceeding.

BUGS

Please report them.

SEE ALSO

IDS::Test, IDS::DataSource

1 POD Error

The following errors were encountered while parsing the POD:

Around line 280:

You forgot a '=back' before '=head2'