NAME
Lingua::Thesaurus::Storage::SQLite - Thesaurus storage in an SQLite database
DESCRIPTION
This class implements the Lingua::Thesaurus::Storage role, by storing thesaurus data in a DBD::SQLite database.
METHODS
new
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 :
- dbname
-
Filename for storing the DBD::SQLite database. This could also be
:memory:
for an in-memory database. - dbh
-
Optional handle to an already connected database (in that case, the
dbname
parameter will not be used). - params
-
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 :
- use_fulltext
-
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*'
.If true, the
term
table is just a regular SQLite table, and queries will be interpreted through SQLite's'LIKE'
operator. - use_unaccent
-
This parameter only makes sense together with
use_fulltext
. It will activate "unaccent" in Search::Tokenizer, so that a query forthésaurus
will also findthesaurus
, or vice-versa. - term_class
-
Name of the class for instanciating terms. Default is Lingua::Thesaurus::Term.
- relType_class
-
Name of the class for instanciating "relation types". Default is Lingua::Thesaurus::RelType.
Retrieval methods
See "Retrieval methods" in Lingua::Thesaurus::Storage
Populating the database
See "Populating the database" in Lingua::Thesaurus::Storage for the API.
Below are some particular notes about the SQLite implementation.
do_transaction
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.
store_term
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.