Business-CompanyDesignator
view release on metacpan or search on metacpan
lib/Business/CompanyDesignator.pm view on Meta::CPAN
$local_datafile = "$Bin/../share/company_designator.yml";
return $local_datafile if -f $local_datafile;
# Installed version
return dist_file('Business-CompanyDesignator', 'company_designator.yml');
});
# data is the raw dataset as loaded from datafile, keyed by long designator
has data => ( is => 'ro', lazy_build => 1 );
# regex_cache is a cache of regexes by language and type, since they're expensive to build
has 'regex_cache' => ( is => 'ro', isa => 'HashRef', default => sub { {} } );
# abbr_long_map is a hash mapping abbreviations (strings) back to an arrayref of
# long designators (since abbreviations are not necessarily unique)
has 'abbr_long_map' => ( is => 'ro', isa => 'HashRef', lazy_build => 1 );
# pattern_string_map is a hash mapping patterns back to their source string,
# since we do things like add additional patterns without diacritics
has 'pattern_string_map' => ( is => 'ro', isa => 'HashRef', default => sub { {} } );
# pattern_string_map_lang is a hash of hashes, mapping language codes to hashes
# of patterns back to their source string
has 'pattern_string_map_lang' => ( is => 'ro', isa => 'HashRef', default => sub { {} } );
sub _build_data {
my $self = shift;
YAML::LoadFile($self->datafile);
}
sub _build_abbr_long_map {
my $self = shift;
my $map = {};
while (my ($long, $entry) = each %{ $self->data }) {
lib/Business/CompanyDesignator/Record.pm view on Meta::CPAN
package Business::CompanyDesignator::Record;
use Moose;
use utf8;
use warnings qw(FATAL utf8);
use Carp;
use namespace::autoclean;
has 'long' => ( is => 'ro', isa => 'Str', required => 1 );
has 'record' => ( is => 'ro', isa => 'HashRef', required => 1 );
has [qw(abbr1 lang)] => ( is => 'ro', lazy_build => 1 );
has 'abbr' => ( is => 'ro', isa => 'ArrayRef[Str]', lazy => 1, builder => '_build_abbr',
reader => '_abbr', traits => [ qw(Array) ], handles => { abbr => 'elements' } );
sub _build_abbr {
my $self = shift;
my $abbr_std = $self->record->{abbr_std};
my $abbr = $self->record->{abbr} || [];
$abbr = [ $abbr ] if ! ref $abbr;
push @$abbr, $abbr_std if $abbr_std;
return $abbr;
}
lib/Business/CompanyDesignator/SplitResult.pm view on Meta::CPAN
package Business::CompanyDesignator::SplitResult;
use Moose;
use utf8;
use warnings qw(FATAL utf8);
use Carp;
use namespace::autoclean;
has [ qw(before after designator designator_std) ] =>
( is => 'ro', isa => 'Str', required => 1 );
has 'records' => ( is => 'ro', isa => 'ArrayRef', required => 1 );
sub short_name {
my $self = shift;
return $self->before || $self->after // '';
}
sub extra {
my $self = shift;
return $self->before ? ($self->after // '') : '';
}
( run in 0.855 second using v1.01-cache-2.11-cpan-5f2e87ce722 )