Lingua::Thesaurus::Storage::SQLite - Thesaurus storage in an SQLite database
This class implements the Lingua::Thesaurus::Storage role, by storing thesaurus data in a DBD::SQLite database.
my $storage = Lingua::Thesaurus::Storage::SQLite->new($dbname); my $storage = Lingua::Thesaurus::Storage::SQLite->new(%args);
If new() has only one scalar argument, this is interpreted as new(dbname => $arg). Otherwise, parameters should be passed as a hash or hashref, with the following options :
new()
new(dbname => $arg)
Filename for storing the DBD::SQLite database. This could also be :memory: for an in-memory database.
:memory:
Optional handle to an already connected database (in that case, the dbname parameter will not be used).
dbname
Hashref of key-value pairs that will be stored into the database, and can be retrieved by other processes using the thesaurus. This package interprets the following keys :
If true, the term table will use SQLite's fulltext functionalities. This means that $thesaurus->search_terms('sci*') will also retrieve 'computer science'; you can also issue boolean queries like 'sci* AND NOT comp*'.
term
$thesaurus->search_terms('sci*')
'computer science'
'sci* AND NOT comp*'
If true, the term table is just a regular SQLite table, and queries will be interpreted through SQLite's 'LIKE' operator.
'LIKE'
This parameter only makes sense together with use_fulltext. It will activate "unaccent" in Search::Tokenizer, so that a query for thésaurus will also find thesaurus, or vice-versa.
use_fulltext
thésaurus
thesaurus
Name of the class for instanciating terms. Default is Lingua::Thesaurus::Term.
Name of the class for instanciating "relation types". Default is Lingua::Thesaurus::RelType.
See "Retrieval methods" in Lingua::Thesaurus::Storage
See "Populating the database" in Lingua::Thesaurus::Storage for the API.
Below are some particular notes about the SQLite implementation.
This method just performs begin_work .. commit, because inserts into an SQLite database are much faster under a transaction. No support for rollbacks is programmed, because in this context there is no need for it.
begin_work
commit
If use_fulltext is false, terms are stored in a regular table with a UNIQUE constraint, so it is not possible to store the same term string twice.
If use_fulltext is true, no constraint is enforced.
To install Lingua::Thesaurus, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Lingua::Thesaurus
CPAN shell
perl -MCPAN -e shell install Lingua::Thesaurus
For more information on module installation, please visit the detailed CPAN module installation guide.