Lingua::Thesaurus::Storage - Role for thesaurus storage
This role specifies the interface for thesaurus storage classes.
Implementation for "search_terms" in Lingua::Thesaurus.
Implementation for "fetch_term" in Lingua::Thesaurus.
Implementation for "related" in Lingua::Thesaurus::Term.
Implementation for "rel_types" in Lingua::Thesaurus.
Implementation for "fetch_rel_type" in Lingua::Thesaurus.
Called by an IO class to initialize storage before a load operation.
$coderef within a transaction. This is used by "load" in Lingua::Thesaurus::IO to store all terms and relations in a single step.
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
$storage->store_rel_type($rel_id, $description, $is_external);
Stores a new relation type.
$rel_idis a unique identifier string for this relation type (such as
$descriptionis an optional free text description
$is_externalis a boolean which tells whether related items will be other terms or external data.
$storage->store_relation($term_id, $rel_id, $related, $is_external, $inverse_id);
Stores a relation, where
$term_idis the unique identifier for the first term in the relation
$rel_idis the unique identifier for relation type
$relatedis an arrayref of items to relate to the term; if
$is_externalis true, these items can be any scalar; if
$is_externalis 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_externalis a boolean which tells what kind of items are related, as explained above
$inverse_idis the optional identifier of the inverse relation type; if non-null, relations will be stored in both directions.
Will be called by IO classes after loading files. Storage implementations may use this to perform cleanup operations if needed.