DTA-CAB

 view release on metacpan or  search on metacpan

CAB/Analyzer.pm  view on Meta::CPAN

## 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 DTA::CAB::Datum ':all';
use DTA::CAB::Utils ':minmax', ':files', ':time';
use File::Basename qw(basename dirname);
use Scalar::Util qw(weaken);
use Exporter;
use Carp;
use strict;

##==============================================================================
## Globals
##==============================================================================

our @ISA = qw(Exporter DTA::CAB::Persistent);

CAB/Analyzer.pm  view on Meta::CPAN

}

## \&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

	   .($code =~ /\bsub\b/ ? $code : "sub { $code }")
	  );

  print 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

		    '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.681 second using v1.01-cache-2.11-cpan-65fba6d93b7 )