Andrew Sterling Hanenkamp > Contentment-0.011_033 > Contentment::Term

Download:
Contentment-0.011_033.tar.gz

Annotate this POD

Source  

NAME ^

Contentment::Term - Interface for Index plugin terms

SYNOPSIS ^

  package Contentment::MyPlugin::Term;

  use Scalar::Util qw( weaken );

  sub new {
      my ($class, $p) = @_;

      my $self = bless {
          name       => $p->{name},
          index      => $p->{index},
          generators => $p->{generators},
      }, $class;

      weaken $self->{index};

      return $self;
  }

  sub name       { return shift->{name} }
  sub index      { return shift->{index} }
  sub generators { return shift->{generators} }

DESCRIPTION ^

Each term object must implement the features described here. The actual features available in a term depend partly upon the features() method of the index object returning the term.

METHODS

These are the methods that all terms must define:

$name = $term->name

This method will return the full string identifying the term. This string should uniquely identify the term within the index.

$title = $term->title

This can be used to give the term a pretty name.

$description = $term->description

This can used to give the term a description.

$index = $term->index

This method will return the original index that spawned it.

@generators = $term->generators

This method will return the list (possibly empty) of generators associated with this term. In the case of a term for an index with the $SUBTERMS feature, this should only return the generators which identified directly by the current term.

SEARCH METHODS

A term for an index with the $SEARCH feature does not need to define any additional methods.

TERM LIST METHODS

A term for an index with the $TERM_LIST feature does not need to define any additional methods.

FREEFORM METHODS

A term for an index with the $FREEFORM_TERMS feature does not need to define any additional methods.

SUBTERM METHODS

A term for an index with the $SUBTERMS feature must define the following methods:

@terms = $term->subterms

Returns a list (possibly empty) of all the subterms of the current term.

@generators = $term->all_generators

Returns a list (possibly empty) of all generators held directly within this term and indirectly by being held within a subterm. Each generator should be returned exactly once.

TERM LINKS METHODS

A term for an index with the $TERM_LINKS feature must define the following methods:

@terms = $term->related_terms

Returns a list (possibly empty) of related terms.

SYNONYM METHODS

A term for an index with the $SYNONYMS feature must define the following methods:

@synonyms = $term->synonyms

Returns a list (possibly empty) of alternate strings that could be used as the name of the current term.

QUANTITATIVE METHODS

A term for an index with the $QUANTITATIVE feature does not need to define any additional methods.

REVERSIBLE METHODS

A term for an index with the $REVERSE feature does not need to define any additional methods.

SCORED METHODS

A term for an index with the $SCORE feature must define the following methods:

$score = $term->score($generator)

This method returns the score of the term match for the given generator. If the generator is not listed by the generators() method, the score must be 0. Otherwise, the score must be a positive number less than or equal to 100.

@scored_generators = $term->scored_generators

This method should return the same thing as the generators() method, except that each element is not a generator, but a two element array. The first element of the array is the score (a positive number less than or equal to 100). The second element of the array is the generator object.

EDIT METHODS

A term for an index with the $EDIT feature must define the following methods:

$term->add_generator($generator)

This method adds the given generator to the list of generators returned by generators() or throws an exception to indicate failure.

$term->remove_generator($generator)

This method removes the given generator from the list of generators returned by generators() or throws an exception to indicate failure.

AUTHOR ^

Andrew Sterling Hanenkamp, <hanenkamp@cpan.org>

LICENSE AND COPYRIGHT ^

Copyright 2005 Andrew Sterling Hanenkamp <hanenkamp@cpan.org>. All Rights Reserved.

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

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

syntax highlighting: