App-FilterUtils
view release on metacpan or search on metacpan
lib/App/FilterUtils/unpt.pm view on Meta::CPAN
use strict;
use warnings;
package App::FilterUtils::unpt;
# ABSTRACT: Strip all dots on Arabic letters in input
our $VERSION = '0.002'; # VERSION
use base 'App::Cmd::Simple';
use utf8;
use charnames qw();
use open qw( :encoding(UTF-8) :std );
use Getopt::Long::Descriptive;
use utf8;
use Unicode::Normalize;
=pod
=encoding utf8
=head1 NAME
unpt - Strip all dots on Arabic letters in input
=head1 SYNOPSIS
$ echo "Ø®ÙØ®" | unpt
ØÙØ
=head1 OPTIONS
=head2 version / v
Shows the current version number
$ unpt --version
=head2 help / h
Shows a brief help message
$ unpt --help
=cut
sub opt_spec {
return (
[ 'version|v' => "show version number" ],
[ 'help|h' => "display a usage message" ],
);
}
sub validate_args {
my ($self, $opt, $args) = @_;
if ($opt->{'help'}) {
my ($opt, $usage) = describe_options(
$self->usage_desc(),
$self->opt_spec(),
);
print $usage;
print "\n";
print "For more detailed help see 'perldoc App::FilterUtils::unpt'\n";
print "\n";
exit;
}
elsif ($opt->{'version'}) {
print $App::FilterUtils::unpt::VERSION, "\n";
exit;
}
return;
}
sub execute {
my ($self, $opt, $args) = @_;
my $readarg = @$args ? sub { shift @$args } : sub { <STDIN> };
while (defined ($_ = $readarg->())) {
chomp;
$_ = NFD($_) =~ s/\p{Mn}//rg; # strip tashkeel
# handle special cases
s/Ù\b/ÙÙ/g;
s/[ÙÚ¹Ú»Ú¼Ú½](?!\b)/Ù®/g;
tr # strip dots in arabic
{بتث جخ ذ ز ش ض ظ غ ٠٠٠ة ٠}
{ٮٮٮ ØØ د ر س ص Ø· ع Ú¡ Ù¯ Úº Ù Ù };
tr # strip in other langs
{Ù¹ÙºÙ»Ù¼Ù½Ù¾Ù¿Ú ÚÚÚÚ¿ÚÚ
ÚÚ ÚÚÚÚÚÚÚÚÚ ÚÚÚÚÚÚÚÚÚ ÚÚÚ ÚÚ Ú Ú Ú¡Ú¢Ú£Ú¤Ú¥Ú¦ Ú§Ú¨ ػؼ ÚµÚ¶Ú·Ú¸ Ú¹Ú»Ú¼Ú½ ÛÛÛÛ ÛÛ
ÛÛÛÛÛÛÛ ÛØ½Ø¾Ø¿ÛÛÛ Û}
{ٮٮٮٮٮٮٮٮ ØØØØØØØØ ددددددددد ررررررررر سسس صص Ø· ع Ú¡Ú¡Ú¡Ú¡Ú¡Ú¡ ٯٯ ÙÙ ÙÙÙÙ ÚºÚºÚºÚº ÙÙÙÙ ÙÙÙÙÙÙÙÙÙ ÙÙÙÙÙÙÙ Û};
print $_, "\n";
}
return;
}
1;
__END__
=head1 GIT REPOSITORY
L<http://github.com/athreef/App-FilterUtils>
=head1 SEE ALSO
L<The Perl Home Page|http://www.perl.org/>
( run in 0.551 second using v1.01-cache-2.11-cpan-140bd7fdf52 )