NAME
Lingua::Thesaurus::Storage - Role for thesaurus storage
DESCRIPTION
This role specifies the interface for thesaurus storage classes.
METHODS
Retrieval methods
search_terms
Implementation for "search_terms" in Lingua::Thesaurus.
fetch_term
Implementation for "fetch_term" in Lingua::Thesaurus.
related
Implementation for "related" in Lingua::Thesaurus::Term.
rel_types
Implementation for "rel_types" in Lingua::Thesaurus.
fetch_rel_type
Implementation for "fetch_rel_type" in Lingua::Thesaurus.
Populating the database
initialize
Called by an IO class to initialize storage before a load operation.
do_transaction
$storage->do_transaction($coderef);
Will execute $coderef
within a transaction. This is used by "load" in Lingua::Thesaurus::IO to store all terms and relations in a single step.
store_term
my $term_id = $storage->store_term($term_string);
Stores a new term, and returns the unique storage id for this term. Depending on the implementation, an exception could be raised if several attempts are made to store the same $term_string
.
store_rel_type
$storage->store_rel_type($rel_id, $description, $is_external);
Stores a new relation type.
$rel_id
is a unique identifier string for this relation type (such as'NT'
or'UF'
).$description
is an optional free text description$is_external
is a boolean which tells whether related items will be other terms or external data.
store_relation
$storage->store_relation($term_id, $rel_id, $related,
$is_external, $inverse_id);
Stores a relation, where
$term_id
is the unique identifier for the first term in the relation$rel_id
is the unique identifier for relation type$related
is an arrayref of items to relate to the term; if$is_external
is true, these items can be any scalar; if$is_external
is false, items should be identifiers of other terms.The storage should preserve the order of items in
$related
, i.e. the "related" method should return items in the same order.$is_external
is a boolean which tells what kind of items are related, as explained above$inverse_id
is the optional identifier of the inverse relation type; if non-null, relations will be stored in both directions.
finalize
Will be called by IO classes after loading files. Storage implementations may use this to perform cleanup operations if needed.