Biblio-Thesaurus-SQLite
view release on metacpan or search on metacpan
lib/Biblio/Thesaurus/SQLite.pm view on Meta::CPAN
sub deleteTerm {
my $termo = shift or die;
my $rel = shift or die;
my $def = shift or die;
my $dbfile = shift or die;
# connect to the database
my $db = DBIx::Simple->connect('dbi:SQLite:' . $dbfile)
or die DBIx::Simple->error;
$db->query('DELETE FROM rel WHERE term = ? AND rel = ? AND def = ?',
$termo, $rel, $def);
$db->query('DELETE FROM rel WHERE term = ? AND rel = ? AND def = ?',
$def, $rel, $termo);
}
##
# Change the term in the database
# @param term to change
# @param old relation
# @param old definition
# @param new relation
# @param new definition
# @param the sqlite database file
sub changeTerm {
my $termo = shift or die;
my $oldrel = shift or die;
my $olddef = shift or die;
my $newrel = shift or die;
my $newdef = shift or die;
my $dbfile = shift or die;
deleteTerm($termo, $oldrel, $olddef, $dbfile);
# use our beautiful setTerm :)
setTerm($termo, $newrel, $newdef, $dbfile);
}
1;
__END__
=head1 NAME
Biblio::Thesaurus::SQLite - Perl extension for managing ISO thesaurs into a SQLite database
=head1 SYNOPSIS
use Biblio::Thesaurus::SQLite;
ISOthe2TheSql('thesaurus', 'dbfile');
TheSql2ISOthe('dbfile', 'output_file');
getTermAsXHTML('term', 'dbfile');
getTermAsISOthe('term', 'dbfile');
getTermAsPerl('term', 'dbfile');
setTerm('term', 'rel', 'definition', 'dbfile');
deleteTerm('term', 'rel', 'definition');
changeTerm('term', 'oldrel', 'olddef', 'newrel', 'newdef', 'dbfile');
=head1 DESCRIPTION
This module provides transparent methods to maintain Thesaurus files
in a backend SQLite database. The module uses a subset from ISO 2788
which defines some standard
features to be found on thesaurus files. The module also supports
multilingual thesaurus and some extensions to the ISOs standard.
=head1 METHODS
=over
=item ISOthe2TheSql THESAURUS, DBFILE
This method reads a ISO thesaurus ASCII file, and converts it to a
SQLite database, stored on 'DBFILE'.
B<WARNING>: This method will erase any existing DB with DBFILE filename
=item TheSql2ISOthe DBFILE, THESAURUS
This method dumps the SQLIte thesaurus database DBFILE to a file THESAURUS,
and tries to
write a beautiful (or not) ISO thesaurus format.
=item getTermAs<FORMAT> TERM, DBFILE
Search in the database for info about this term and outputs it in the
following FORMAT:
=over
=item XHTML
Usefull (or not yet) to use in CGI modules. A simple table is used to write
the output of the query.
=item ISOThesaurus
Tries to output the info about the term in a ISO Thesaurus text format.
=item Perl
Constructs a Perl structure (see the "picture" below) and outputs the
text representation of it using the Data::Dumper format
ovo => {
NT => [_, _, _]
SN => [_, _, _]
}
=back
=item setTerm TERM, RELATION, DEFINITION, DBFILE
This method tries to blindly add information about the term into the
SQLite database... Much work to be done here...
=item deleteTerm TERM, RELATION, DEFINITION, DBFILE
This simple deletes the TERM with the RELATION and DEFINITION from the database
=item changeTerm TERM, OLDRELATION, OLDDEFINITION, NEWRELATION, NEWDEFINITION, DBFILE
( run in 2.021 seconds using v1.01-cache-2.11-cpan-39a47a84364 )