NAME

DTA::CAB::Analyzer::Dict::BDB - generic analysis dictionary API using Lingua::TT::DBFile

SYNOPSIS

##========================================================================
## PRELIMINARIES

use DTA::CAB::Analyzer::Dict::BDB;

##========================================================================
## Constructors etc.

$obj = CLASS_OR_OBJ->new(%args);
$dic = $dic->clear();

##========================================================================
## Methods: Embedded API

$bool = $dic->dictOk();
\%key2val = $dict->dictHash();
$val_or_undef = $dict->dictLookup($key);

##========================================================================
## Methods: I/O

$bool = $dic->ensureLoaded();

##========================================================================
## Methods: Persistence: Perl

@keys = $class_or_obj->noSaveKeys();
$loadedObj = $CLASS_OR_OBJ->loadPerlRef($ref);

DESCRIPTION

Globals

Variable: @ISA

DTA::CAB::Analyzer::Dict::BDB inherits from DTA::CAB::Analyzer::Dict and supports the DTA::CAB::Analyzer API. This module uses Lingua::TT::DBFile to implement a static finite dictionary stored in a Berkeley DB file.

Constructors etc.

new
$obj = CLASS_OR_OBJ->new(%args);

%$obj, %args:

##-- Filename Options
dictFile => $filename,    ##-- DB filename (default=undef)
##
##-- Analysis Output
label          => $lab,   ##-- analyzer label
analyzeCode    => $code,  ##-- pseudo-accessor code for analyzeing token $_
##
##-- Analysis Options
encoding       => $enc,   ##-- encoding of db file (default='UTF-8'): clobbers $dba{encoding}
##
##-- Analysis objects
dbf => $dbf,              ##-- underlying Lingua::TT::DBFile object (default=undef)
dba => \%dba,             ##-- args for Lingua::TT::DBFile->new()
#={
#  mode    => $mode,      ##-- default: 0644
#  flags   => $flags,     ##-- default: O_RDONLY
#  type    => $type,      ##-- one of 'HASH', 'BTREE', 'RECNO', 'GUESS' (default: 'GUESS')
#  dbinfo  => \%dbinfo,   ##-- default: "DB_File::${type}INFO"->new();
#  dbopts  => \%opts,     ##-- db options (e.g. cachesize,bval,...) -- defaults to none (uses DB_File defaults)
# }
clear
$dic = $dic->clear();

Overriude just closes db.

Methods: Embedded API

dictOk
$bool = $dic->dictOk();

Should returns false iff dict is undefined or "empty". Override just checks whether the underlying DB file has been successfully opened.

dictHash
\%key2val = $dict->dictHash();

Returns a (possibly tie()d hash) representing dict contents. Override returns $dict->{dbf}{data} or a new empty hash.

dictLookup
$val_or_undef = $dict->dictLookup($key);

Get stored value for key $key, if any. Default returns $dict->{ttd}{dict}{$key} or undef.

Methods: I/O

ensureLoaded
$bool = $dic->ensureLoaded();

Ensures analyzer data is loaded from default files. Override instantiates $dic->{dbf} as a new Lingua::TT::DBFile object.

Methods: Persistence: Perl

noSaveKeys
@keys = $class_or_obj->noSaveKeys();

Returns list of keys not to be saved. Default adds qw(dbf) to superclass list.

loadPerlRef
$loadedObj = $CLASS_OR_OBJ->loadPerlRef($ref);

Load object data from a perl reference. Probably a dangerous thing to do on an open DB.

AUTHOR

Bryan Jurish <moocow@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2011-2019 by Bryan Jurish

This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.24.1 or, at your option, any later version of Perl 5 you may have available.

SEE ALSO

dta-cab-analyze.perl(1), DTA::CAB::Analyzer::Dict(3pm), DTA::CAB::Analyzer(3pm), DTA::CAB::Chain(3pm), DTA::CAB(3pm), perl(1), ...