Lingua::LangId::Map - language identification utilities: language classifier


(Back to Top)


NAME

Lingua::LangId::Map - language identification utilities: language classifier

(Back to Top)


SYNOPSIS

 ##========================================================================
 ## PRELIMINARIES
 use Lingua::LangId::Map;
 ##========================================================================
 ## Constructors etc.
 $map = $CLASS_OR_OBJECT->new(%opts);
 @noShadowKeys = $obj->noShadowKeys();
 ##========================================================================
 ## Methods: Compilation
 $map_or_undef = $map->compile();
 $map = $map->addSig($sig);
 ##========================================================================
 ## Methods: Testing
 $sig = $map->newSig(%opts);
 \%rh = $map->applyFile($filename_or_fh,%opts);
 \%rh = $map->applyString($str,%opts);
 \%rh = $map->applySig($sig2);
 \%rh = $sig->apply(file=>$filename_or_fh,%opts);

(Back to Top)


DESCRIPTION

Globals & Constants

Variable: @ISA

Lingua::LangId::Map inherits from Lingua::LangId::Object.

Constructors etc.

new
 $map = $CLASS_OR_OBJECT->new(%opts);

%opts, %$sig:

 sigs => \%label2sig,  ##-- each $sig also has a key 'label'
 template => $sig,     ##-- template for creating new sigs (default: undef)
                       ## + if undef, first sig added with addSig() will be shadowed & used
 #...
noShadowKeys
 @noShadowKeys = $obj->noShadowKeys();

Returns list of keys not to be passed to $CLASS->new() on shadow(). Override returns qw(sigs).

Methods: Compilation

compile
 $map_or_undef = $map->compile();

Compiles all sub-signatures

addSig
 $map = $map->addSig($sig);
 $map = $map->addSig($sig,%opts)

%opts:

 label=>$label

Add signature $sig to map inventory with label $label. Sets $sig->{label}. Default label is "$sig".

Methods: Testing

newSig
 $sig = $map->newSig(%opts);

New signature from $map->{template} %opts are passed to Lingua::LangId::Signature->new().

applyFile
 \%rh = $map->applyFile($filename_or_fh,%opts);

Trains new signature from $file and applies. %opts are passed to Lingua::LangId::Signature->new().

applyString
 \%rh = $map->applyString($str,%opts);
 \%rh = $map->applyString(\$str,%opts)

Trains new signature from $file and applies

applySig
 \%rh = $map->applySig($sig2);

Compares $sig vs. each signature in $map->{sigs} Result-hash %rh is:

 $sigName => \%sig_rh, ...  ##-- for each $sigName in $map->{sigs}

Each %sig_rh is:

 kld  => $raw_kld,         ##-- raw comparison
 klde => $expected_kld,    ##-- expected KLD for $sig2->N
 kldp => $kld_p,           ##-- comparison p-value as returned by $sig->kldp($sig2)
 match => $bool,           ##-- true iff $kldp >= $sig->{cutoff}
apply
 \%rh = $sig->apply(file=>$filename_or_fh,%opts);
 \%rh = $sig->apply(str=>$string_or_ref,%opts);
 \%rh = $sig->apply(sig=>$sig,%opts);

(Back to Top)


SEE ALSO

Lingua::LangId(3pm)

(Back to Top)


AUTHOR

Bryan Jurish <jurish@uni-potsdam.de>

(Back to Top)


COPYRIGHT AND LICENSE

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

(Back to Top)

 Lingua::LangId::Map - language identification utilities: language classifier