Lingua-Boolean-Tiny
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/Lingua/Boolean/Tiny.pm view on Meta::CPAN
return 1 if fc $text eq fc $self->yes;
return 0 if fc $text eq fc $self->no;
return 1 if match($text, $self->yes_expr);
return 0 if match($text, $self->no_expr);
return 1 if $text eq 1;
return 0 if $text eq 0;
return undef;
}
sub yesno
{
$_[1] ? $_[0]->yes : $_[0]->no
}
sub make_classes
{
my $base = shift;
no strict 'refs';
for (@_)
{
my ($lang, $codes, $yes, $no, $yes_expr, $no_expr) = @$_;
$yes_expr = $yes unless defined $yes_expr;
$no_expr = $no unless defined $no_expr;
my $class = "Lingua::Boolean::Tiny::$lang";
${"$class\::AUTHORITY"} = $AUTHORITY;
${"$class\::VERSION"} = $VERSION;
@{"$class\::ISA"} = ($base);
no warnings qw( closure );
eval qq
{
package $class;
sub new { my \$k = shift; bless qr{$lang}, \$k };
sub yes { \$yes };
sub no { \$no };
sub yes_expr { \$yes_expr };
sub no_expr { \$no_expr };
sub languages { \$lang };
sub langs { \@{ \$codes } };
};
for my $lang (@$codes)
{
$Lingua::Boolean::Tiny::LANG{$lang} = $class;
}
push @Lingua::Boolean::Tiny::LANG, $codes->[0];
}
return 1;
}
}
{
package Lingua::Boolean::Tiny::Union;
our $AUTHORITY = 'cpan:TOBYINK';
our $VERSION = '0.008';
sub new
{
my $class = shift;
bless [ grep defined, map "Lingua::Boolean::Tiny"->new_strict($_), @_ ] => $class;
}
sub boolean
{
my $self = shift;
for (@$self)
{
my $r = $_->boolean(@_);
return $r if defined $r;
}
return undef;
}
sub langs
{
my $self = shift;
map $_->langs, @$self;
}
sub languages
{
my $self = shift;
map $_->languages, @$self;
}
}
"Lingua::Boolean::Tiny::BASE"->make_classes(
[
Chinese => [qw( zh zho chi )],
q/æ¯/ => q/ä¸æ¯/,
[qr{^[yYæ¯]}, qw( æ¯ å° æ¯ å¯¹ ), qr{^[ds]h[ìi]$}i],
[qr{^[nNä¸å¦]}, qw( ä¸æ¯ ä¸å° ä¸æ¯ ä¸å¯¹ ), qr{^b[úu]\s*[ds]h[ìi]$}i],
],
[
English => [qw( en eng )],
qw( yes no ),
[qr{^y(?:es)?$}i, qr{^on$}i, qr{^ok$}i, qr{^true$}i],
[qr{^no?$}i, qr{^off$}i, qr{not ?ok$}i, qr{^false$}i],
],
[
Spanish => [qw( es spa )],
qw( sà no ),
qr{^[sSyY]},
qr{^[nN]$},
],
[
Hindi => [qw( hi hin )],
q/हाà¤/ => q/नहà¥à¤/,
["हाà¤", qr{^h[aÄ]Ì$}i, "à¤à¥", qr{^j[Ä«i]$}i, "à¤à¥ हाà¤", qr{^j[Ä«i]\s*h[aÄ]Ì$}i, qr{^ji\s*ha$}i, qr{^[yY]}],
["नहà¥à¤", qr{^nahÄ«Ì$}i, "à¤à¥ नहà¥à¤", qr{^jÄ« nahÄ«Ì$}i, qr{^ji\s*nahi$}i, qr{^[nN]}],
],
[
Russian => [qw( ru rus )],
qw( да Ð½ÐµÑ ),
[qr{^[ÐдYy]}, qr{^да$}i, qr{^da$}i],
[qr{^[ÐнNn]}, qr{^неÑ$}i, qr{^n[iy]?et$}i],
],
[
Arabic => [qw( ar ara )],
q/ÙعÙ
/ => q/ï»»/,
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.037 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )