Search
Categories
Documents
README
Thesaurus - Maintains lists of associated items (Displayed)
|
Thesaurus - Maintains lists of associated items
Thesaurus - Maintains lists of associated items
use Thesaurus;
$th = new Thesaurus( -files => [ 'file1', 'file2' ],
-ignore_case => 1 );
@words = $th->find('vegan');
%words = $th->find( 'animal', 'liberation' );
foreach $word ( @{ $words{animal} } )
{
#something ...
}
$th->add_file( 'file1', 'file2' );
$th->add( 'tofu', 'mock duck' );
$th->delete( 'meat', 'vivisection' );
Thesaurus is a module that allows you to create lists of related
things. It was created in order to facilitate searches of a database
of Chinese names in Anglicized form. Because there are various
schemes to create phonetic representations of Chinese words, the
following can all represent the same Chinese character:
Woo
Wu
Ng
Thesaurus can be used for anything that fits into a scalar by using
the new method with no parameters and then calling the add
method to add data.
Thesaurus also acts as the parent class to several child classes which
implement various forms of persistence for the data structure. This
module can be used on its own to instantiate an object that lives for
the life of its scope.
@words = $th->find( 'Big Hat' );
%words = $th->find( 'Big Hat', 'Faye Wong' );
The find method returns either a list or a hash, depending on
context. Given a single word to find, it returns the list of words
that it is associated with, including the word that was given. If no
matches are found then it returns an empty list.
If it is given multiple words, it returns a hash. The keys of the has
are the words given, and the keys are list references containing the
associated words. If no words were found then the key has a value of
0. If none of the words match then an empty list is returned.
add( \@list1, \@list2 )
The add method takes a list of list references. Each of these
references should contain a set of associated scalars. Like the add
files method, if an entry in the files matches an entry already
in the object, then it is appended to the existing list, otherwise a
new entry is created.
delete( @items )
The delete method takes a list of items to delete. All the
associations for the given items will be removed.
all
Returns a list of array references. Each one of these list references
contains one set of associations. Each association list is returned
once, not once per item it contains.
Dave Rolsky, <autarch@urth.org>
Thesaurus::CSV, Thesaurus::BerkeleyDB
Copyright (c) 1999-2002 David Rolsky. All rights reserved. This
program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
Information
|
This site is currently in testing, it is not yet operating using the full database. Until it is officially launched you may wish to visit Help-Site Computer Manuals. After launch, this site (HelpSpy) will replace Help-Site. Information about the spider which is currently trawling the Internet looking for links to add to this directory can be found here. |
|