Thesaurus::DBI - Store and query synonyms (Thesaurus) in an SQL database.
use Thesaurus::DBI; # create new database connection my $th = new Thesaurus::DBI(dbhost=> 'localhost', dbname=>'thesaurus',dbuser=>'user',dbpassword=>'pass'); # use existing database connection my $th = new Thesaurus::DBI(dbhandle => $dbi, dbname=>'thesaurus',dbuser=>'user',dbpassword=>'pass'); # initialize database $th->create_tables(); # query thesaurus my @synonyms = $th->find('synonym'); # add synonyms $th->add(['word', 'synonym']); # delete word $th->delete('word');
This subclass of Thesaurus implements persistence by using an SQL database.
Thesaurus
This module requires the DBI module from CPAN. To use it with certain database servers, the corresponding database drivers are needed, too. (Mysql -> DBD::mysql)
DBI
Please note, that database servers like MySQL doesn't take care of case-sensitivity. So the queries to the thesaurus-database wil all bei case-insensitive.
new
This subclass's new method takes the following parameters, in addition to those accepted by its parent class:
dbhost => 'localhost'
Host of the database server. Default value: localhost
dbname => 'thesaurus'
Name of the database to connect to.
dbuser => 'user'
Username for the database connection
dbpassword => 'pass'
Password for the database connection
dbhandle => $dbi
If you already have an existing connection to the database where the thesaurus tables are found in (word, assignment), you can pass it in by using this parameter.
create_tables
Method to initialize the database to store synonyms in. Creates two new database tables to store all words and the corresponding assignments.
Thesaurus, DBI, DBD::mysql
Listed below are some links for synonym databases, that can be used with this module
English
http://www.thesaurus.com/ http://wordnet.princeton.edu/perl/webwn/
Deutsch
http://www.openthesaurus.de
Polish
http://synonimy.ux.pl/
Espanol
http://openoffice-es.sourceforge.net/thesaurus/
Slovenska
http://www.openthesaurus.tk/
Jo Seibert, jseibert (at) seibert-media (dot) net
Copyright (C) 2006 by Jo Seibert
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.
2 POD Errors
The following errors were encountered while parsing the POD:
'=item' outside of any '=over'
You forgot a '=back' before '=head1'
To install Thesaurus::DBI, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Thesaurus::DBI
CPAN shell
perl -MCPAN -e shell install Thesaurus::DBI
For more information on module installation, please visit the detailed CPAN module installation guide.