DTA::CAB::Analyzer::Dict::DB - generic analysis dictionary API using Lingua::TT::DB::File


NAME

DTA::CAB::Analyzer::Dict::DB - generic analysis dictionary API using Lingua::TT::DB::File

(Back to Top)


SYNOPSIS

 ##========================================================================
 ## PRELIMINARIES
 
 use DTA::CAB::Analyzer::Dict::DB;
 
 ##========================================================================
 ## 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);

(Back to Top)


DESCRIPTION

Globals

Variable: @ISA

DTA::CAB::Analyzer::Dict::DB inherits from DTA::CAB::Analyzer::Dict and supports the DTA::CAB::Analyzer API. This module uses Lingua::TT::DB::File 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
 analyzeGet     => $code,  ##-- pseudo-accessor ($code->($tok)): returns list of source keys for token  (default='$_[0]{text}')
 analyzeSet     => $code,  ##-- pseudo-accessor ($code->($tok,$key,$val)) sets analyses for $tok
 ##
 ##-- Analysis Options
 encoding       => $enc,   ##-- encoding of db file (default='UTF-8'): clobbers $dba{encoding}
 ##
 ##-- Analysis objects
 dbf => $dbf,              ##-- underlying Lingua::TT::DB::File object (default=undef)
 dba => \%dba,             ##-- args for Lingua::TT::DB::File->new()
 #={
 #  mode  => $mode,        ##-- default: 0644
 #  dbflags => $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::DB::File 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.

(Back to Top)


AUTHOR

Bryan Jurish <jurish@bbaw.de>

(Back to Top)


COPYRIGHT AND LICENSE

Copyright (C) 2011 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.10.0 or, at your option, any later version of Perl 5 you may have available.

(Back to Top)


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), ...

(Back to Top)

 DTA::CAB::Analyzer::Dict::DB - generic analysis dictionary API using Lingua::TT::DB::File