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

NAME

Lingua::FeatureMatrix::Eme - Abstract base class contains one single eme's features.

SYNOPSIS

TO DO:

  use Lingua::FeatureMatrix::Eme;
  blah blah blah

DESCRIPTION

This class is a container for a list of features. A Lingua::FeatureMatrix object stores a table of these.

What do I use this class for?

Use this class to build your own subtypes for use with Lingua::FeatureMatrix. Lingua::FeatureMatrix::Eme provides the necessary base class methods to interact with Lingua::FeatureMatrix.

Methods exported

The following methods are public (and used by Lingua::FeatureMatrix):

Class methods

new

The new() method will construct and return an object blessed into the current class. In addition, this method will initialize each element of the feature list (returned from the getFeatureList() method) with the string "unset".

Arguments passed to new() will be treated as a hash of name => value pairs. All keys (see exception below) will be treated as method names, and the method will be invoked with the corresponding value (this will ordinarily set the feature named key to value).

NOTE: users will probably rarely invoke this method directly, since the Lingua::FeatureMatrix code builds these objects as needed while configuring itself.

Note also that the key options will be explicitly ignored if present so that subclasses can hang any special initialization values off that argument. This allows users to pass their special arguments to their subclasses via the eme_opts named parameter to Lingua::FeatureMatrix-new()>.

failsContract

Lists how this class fails its own contract. By extension, indicates how a subclass fails the contract. Handy for sanity checking.

Instance methods

->isSpecified

returns whether the feature passed by argument is specified. Will croak if the feature specified is not supported by the class.

->listUnspecified

Returns which features have never been specified. Note this is *not* the same as those features that are undef, since that undef is a value that can legitimately be specified. See "Implicatures" in Lingua::FeatureMatrix for more details.

->isFullySpecified

Returns whether the Eme object in question has had all its features fully specified.

->isEquivalent

Returns whether the Eme object is equivalent to a (different) Eme object of the same class handed in.

Rejects Eme objects of different classes, and issues warnings if any fields needed to make the decision are as yet unset (though undef fields are acceptable).

->listUserSpecified

Returns that list of features that were specified by the user (not by implication).

->listImplicationSpecified

Returns that list of features that were computed by the implications specified while configuring the Lingua::FeatureMatrix parent object.

->hasFeature

Returns feature's value. Note that ungrammatical features will return a false value.

->dumpToText

Dumps textual representation of self's featureset, including the [] brackets. Note any features that were not set by user or by implication will be dumped as ?.

->dumpFeaturesToText

Dumps the features passed by argument, and their value, as a text string.

->explainFeature

Given a featurename, returns a list of the text form of the implications that were used to set that feature. If the feature does not exist, returns undefined.

Subclass requirements

Those who want to build their own subclass should build one to the following specification. Note that the Phone and Letter subclasses provided in the examples/ distribution of Lingua::FeatureMatrix are good places to start.

->getFeatureNames

Any subclass should support a class method getFeatureNames which should return, in some interesting (and ideally reliable) order, the list of features that are supported by the subclass.

feature methods

Each feature listed by getFeatureNames should:

  • be an instance method of the class.

  • return the value of that feature when called with no argument (easily written with Class::MethodMaker).

  • set the value of that feature when called with an argument (easily written with Class::MethodMaker).

  • when called with an argument, must accept the following values:

    0
    1
    undef
    "unset"

    Ignoring or rejecting other values is acceptable.

initialization method

new() should respond as follows:

Either don't provide a new() (let superclass take care of it) or:

  • Get your options from the options key/value pair from the argument list, then:

  • call SUPER::init to be sure that the Eme object handles itself properly.

In general, try to follow OO subclassing best practices, or use the provided examples/Phone.pm and examples/Letter.pm as guides.

It is strongly recommended to use Class::MethodMaker to build the feature subroutines; in fact, that is all the author has tested with.

HISTORY

0.01

Original version; created by h2xs 1.21 with options

  -CAX
        Lingua::FeatureMatrix::Eme
0.02
Now includes the failsContract() class method.
Now supports the isEquivalent() instance method.

AUTHOR

Jeremy Kahn, <kahn@cpan.org>

SEE ALSO

perl.

Lingua::FeatureMatrix.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 403:

Expected text after =item, not a number