DTA-CAB
view release on metacpan or search on metacpan
CAB/Chain.pm view on Meta::CPAN
## -*- Mode: CPerl -*-
##
## File: DTA::CAB::Chain.pm
## Author: Bryan Jurish <moocow@cpan.org>
## Description: generic analyzer API: analyzer "chains" / "cascades" / "pipelines" / ...
package DTA::CAB::Chain;
use DTA::CAB::Analyzer;
use DTA::CAB::Datum ':all';
use Carp;
use strict;
##==============================================================================
## Globals
##==============================================================================
our @ISA = qw(DTA::CAB::Analyzer);
BEGIN {
*isa = \&UNIVERSAL::isa;
*can = \&UNIVERSAL::can;
}
##==============================================================================
## Constructors etc.
##==============================================================================
## $obj = CLASS_OR_OBJ->new(%args)
## + object structure:
## (
## ##-- Analyzers
## chain => [ $a1, $a2, ..., $aN ], ##-- default analysis chain; see also chain() method (default: empty)
##
## ##-- verbose trace
## logTrace => $level, ##-- trace sub-analyzer execution (default: 'none')
## )
sub new {
my $that = shift;
my $ach = bless({
##-- user args
chain => [],
logTrace => 'none',
@_
}, ref($that)||$that);
$ach->initialize();
$ach->{label} = $ach->defaultLabel if (!defined($ach->{label}));
return $ach;
}
## undef = $ach->initialize();
## + default implementation does nothing
## + INHERITED from DTA::CAB::Analyzer
## undef = $ach->dropClosures();
## + drops '_analyze*' closures
## + INHERITED from DTA::CAB::Analyzer
## @keys = $anl->typeKeys(\%opts)
## + returns list of type-wise keys to be expanded for this analyzer by expandTypes()
## + default just concatenates keys for sub-analyzers
sub typeKeys {
my $ach = shift;
return map {ref($_) ? $_->typeKeys(@_) : qw()} @{$ach->chain(@_)}
}
CAB/Chain.pm view on Meta::CPAN
=cut
##========================================================================
## NAME
=pod
=head1 NAME
DTA::CAB::Chain - serial multi-analyzer pipeline
=cut
##========================================================================
## SYNOPSIS
=pod
=head1 SYNOPSIS
use DTA::CAB::Chain;
##========================================================================
## Constructors etc.
$obj = CLASS_OR_OBJ->new(%args);
@keys = $anl->typeKeys(\%opts);
##========================================================================
## Methods: Chain selection
\@analyzers = $ach->chain();
\@analyzers = $ach->subAnalyzers();
##========================================================================
## Methods: I/O
$bool = $ach->ensureLoaded();
##========================================================================
## Methods: Analysis
$bool = $ach->canAnalyze();
$bool = $anl->enabled(\%opts);
undef = $anl->initInfo();
$doc = $ach->analyzeTypes($doc,$types,\%opts);
$doc = $ach->analyzeSentences($doc,\%opts);
$doc = $ach->analyzeLocal($doc,\%opts);
$doc = $ach->analyzeClean($doc,\%opts);
=cut
##========================================================================
## DESCRIPTION
=pod
=head1 DESCRIPTION
DTA::CAB::Chain
is an abstract L<DTA::CAB::Analyzer|DTA::CAB::Analyzer> subclass
for implementing serial document processing "pipelines" or "cascades"
in terms of a flat list of L<DTA::CAB::Analyzer|DTA::CAB::Analyzer> objects.
=cut
##----------------------------------------------------------------
## DESCRIPTION: DTA::CAB::Chain: Constructors etc.
=pod
=head2 Constructors etc.
=over 4
=item new
$obj = CLASS_OR_OBJ->new(%args);
%$obj, %args:
chain => [ $a1, $a2, ..., $aN ], ##-- default analysis chain; see also chain() method (default: empty)
=item typeKeys
@keys = $anl->typeKeys(\%opts);
Returns list of type-wise keys to be expanded for this analyzer by expandTypes()
Default implementation just concatenates typeKeys() for sub-analyzers.
=back
=cut
##----------------------------------------------------------------
## DESCRIPTION: DTA::CAB::Chain: Methods: Chain selection
=pod
=head2 Methods: Chain selection
=over 4
=item chain
\@analyzers = $ach->chain();
\@analyzers = $ach->chain(\%opts)
Get selected analyzer chain.
Default method returns all globally enabled analyzers in $anl-E<gt>{chain}.
=item subAnalyzers
\@analyzers = $ach->subAnalyzers();
\@analyzers = $ach->subAnalyzers(\%opts)
Returns a list of all sub-analyzers.
Override just calls chain().
=back
=cut
##----------------------------------------------------------------
( run in 0.589 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )