DTA-CAB
view release on metacpan or search on metacpan
CAB/Analyzer.pm view on Meta::CPAN
345678910111213141516171819202122## File: DTA::CAB::Analyzer.pm
## Author: Bryan Jurish <moocow@cpan.org>
## Description: generic analyzer API
package
DTA::CAB::Analyzer;
use
DTA::CAB::Persistent;
use
DTA::CAB::Logger;
use
Exporter;
use
Carp;
use
strict;
##==============================================================================
## Globals
##==============================================================================
our
@ISA
=
qw(Exporter DTA::CAB::Persistent)
;
CAB/Analyzer.pm view on Meta::CPAN
520521522523524525526527528529530531532533534535536537538539540}
## \&closure = $anl->getAnalyzeClosure($which)
## + returns closure \&closure for analyzing data of type "$which"
## (e.g. Word, Type, Token, Sentence, Document, ...)
## + default implementation calls $anl->getAnalyze"${which}"Closure() if
## available, otherwise croak()s
sub
getAnalyzeClosure {
my
(
$anl
,
$which
) =
@_
;
my
$getsub
=
$anl
->can(
"getAnalyze${which}Closure"
);
weaken(
$anl
);
return
$getsub
->(
$anl
)
if
(
$getsub
);
$anl
->logconfess(
"getAnalyzeClosure('$which'): no getAnalyze${which}Closure() method defined!"
);
}
##------------------------------------------------------------------------
## Methods: Analysis: (Token-)Accessor Closures
## $closure = $anl->accessClosure( $methodName, %opts);
## $closure = $anl->accessClosure(\&codeRef, %opts);
## $closure = $anl->accessClosure( $codeString, %opts);
CAB/Analyzer.pm view on Meta::CPAN
569570571572573574575576577578579580581582583584585586587588589
.(
$code
=~ /\bsub\b/ ?
$code
:
"sub { $code }"
)
);
STDERR
((
ref
(
$anl
)||
$anl
),
"->accessClosure():\n$code\n"
)
if
(0 || (
ref
(
$anl
) &&
$anl
->{debugAccessClosure}));
my
$do_cache
= !
exists
(
$opts
{cache}) ||
$opts
{cache};
my
$sub
= (
$do_cache
?
$CLOSURE_CACHE
{
$anl
}{
$code
} :
undef
);
my
$cached
=
$sub
? 1 : 0;
weaken(
$anl
);
$sub
||=
eval
$code
;
$anl
->logcluck(
"accessClosure(): could not compile closure {$code}: $@"
)
if
(!
$sub
);
$CLOSURE_CACHE
{
$anl
}{
$code
} =
$sub
if
(
$do_cache
&& !
$cached
);
return
$sub
;
}
## PACKAGE::_am_xlit($tokvar='$_')
## + access-closure macro (EXPR): get text (xlit.latin1Text << text) for token $$tokvar
## + evaluates to a string:
Makefile.PL view on Meta::CPAN
535455565758596061626364656667686970717273'XML::LibXML'
=> 2.0001,
'Template'
=>0,
'LWP::UserAgent'
=>0,
'HTTP::Daemon'
=>0,
'HTTP::Daemon::UNIX'
=>0,
#0.06
##--
'Log::Log4perl'
=> 1.07,
'Unicode::String'
=> 2.09,
'RPC::XML'
=> 0.59,
##
'Scalar::Util'
=> 0,
##-- for weaken()
##
#'Log::Dispatch' => 2.22, ##-- for cab servers, FileRotate
##--
#'DocClassify' => 0.04,
#'Lingua::LangId' => 0.01,
##--
#'Text::Unidecode' => 0.04,
#'Tie::Cache'=>0,
#'Unicode::UCD' =>0,
#'Unicode::CharName' =>0,
( run in 0.329 second using v1.01-cache-2.11-cpan-e9199f4ba4c )