/usr/local/CPAN/Regexp-Ethiopic/Regexp/Ethiopic/Tigrigna.pm
package Regexp::Ethiopic::Tigrigna;
use base qw(Regexp::Ethiopic); # this might be more useful later,
# we at least get "Exporter" for free.
use utf8;
BEGIN
{
use strict;
use vars qw($VERSION @EXPORT_OK %TigrignaEquivalence %TigrignaClassEquivalence);
$VERSION = "0.05";
@EXPORT_OK = qw(%TigrignaEquivalence %TigrignaClassEquivalence);
#
# Tigrigna Rules Orthography Equivalence
#
%TigrignaEquivalence =(
á => "áááá",
á => "áá",
á => "áá",
á => "áá",
á
=> "á
á
",
á => "ááá",
á => "áá",
á° => "á°á ",
á± => "á±á¡",
á² => "á²á¢",
á³ => "á³á£",
á´ => "á´á¤",
áµ => "áµá¥",
á¶ => "á¶á¦",
á· => "á·á§",
á => "áá",
á => "áá",
á => "áá",
á => "áá",
á => "á á£",
á => "áá",
á® => "á®á°",
á¾ => "á¾á",
á => "áá",
Ḡ=> "á¸á",
á¹ => "á¹á",
Ạ=> "áºá",
á» => "á»á",
á¼ => "á¼á",
á½ => "á½á
",
á¾ => "á¾á",
);
foreach (ord('á')..ord('á')) {
my $key = chr($_);
# print "KEY $key / $TigrignaEquivalence{$key}\n";
next if ( $key eq 'á' );
my @values = split (//, $TigrignaEquivalence{$key});
foreach (@values) {
# print " VALUE: $_\n";
$TigrignaEquivalence{$_}
= $TigrignaEquivalence{$key}
;
}
}
$TigrignaEquivalence{'á'}
= $TigrignaEquivalence{'á'}
;
foreach (ord('á°')..ord('á·')) {
my $key = chr($_);
$TigrignaEquivalence{$key} =~ /(\w)$/;
$TigrignaEquivalence{$1}
= $TigrignaEquivalence{$key}
;
}
$TigrignaEquivalence{'á'}
= $TigrignaEquivalence{'á'}
;
$TigrignaEquivalence{'á'}
= $TigrignaEquivalence{'á'}
;
$TigrignaEquivalence{'á'}
= $TigrignaEquivalence{'á'}
;
$TigrignaEquivalence{'á'}
= $TigrignaEquivalence{'á'}
;
$TigrignaEquivalence{'á£'}
= $TigrignaEquivalence{'á '}
;
$TigrignaEquivalence{'á°'}
= $TigrignaEquivalence{'á®'}
;
$TigrignaEquivalence{'á'}
= $TigrignaEquivalence{'á¾'}
;
$TigrignaEquivalence{'á'}
= $TigrignaEquivalence{'á'}
;
$TigrignaEquivalence{'á'}
= $TigrignaEquivalence{'á'}
;
foreach (ord('á¸')..ord('á¾')) {
my $key = chr($_);
$TigrignaEquivalence{$key} =~ /(\w)$/;
$TigrignaEquivalence{$1}
= $TigrignaEquivalence{$key}
;
}
#
# Family Eqivalence
#
%TigrignaClassEquivalence =(
á => "á-áá-áá-á",
á° => "á°-á·á -á§",
Ḡ=> "á¸-á¿á-á"
);
$TigrignaClassEquivalence{'á '}
= $TigrignaClassEquivalence{'á°'}
;
$TigrignaClassEquivalence{'á'}
= $TigrignaClassEquivalence{'á¸'}
;
}
sub import
{
my @args = ( shift ); # package
foreach (@_) {
if ( /overload/o ) {
use overload;
overload::constant 'qr' => \&getRe;
}
elsif ( /EthiopicClasses|(sub|[gs]et)Form|:forms|:utils/ ) {
Regexp::Ethiopic->export_to_level (1, "Regexp::Ethiopic", $_);
}
else {
push (@args, $_);
}
}
if ($#args) {
Regexp::Ethiopic::Tigrigna->export_to_level (1, @args);
}
}
#
# move into Regexp::Ethiopic later...
#
sub getFamilyEquivalent
{
my ($chars) = @_;
return $chars if ( length($chars) == 1 );
$chars =~ s/(\w)(?=\w)/$1,/og;
my @Chars = split ( /,/, $chars );
my $return;
foreach (@Chars) {
$char = $_;
foreach ( keys %TigrignaClassEquivalence ) {
$return .= $_ if ( $TigrignaClassEquivalence{$char} eq $TigrignaClassEquivalence{$_} );
}
}
$return;
}
sub getRe
{
$_ = ($#_) ? $_[1] : $_[0];
s/\[=(\p{Ethiopic})=\]/($TigrignaEquivalence{$1}) ? "[$TigrignaEquivalence{$1}]" : $1/eog;
s/\[=#(\p{Ethiopic})#=\]/($TigrignaClassEquivalence{$1}) ? "[$TigrignaClassEquivalence{$1}]" : $1/eog;
s/\[=#([\p{Ethiopic}]+)#=\]/Regexp::Ethiopic::setRange(getFamilyEquivalent($1),"all")/eog;
Regexp::Ethiopic::getRe ( $_ );
}
#########################################################
# Do not change this, Do not put anything below this.
# File must return "true" value at termination
1;
##########################################################
__END__
=head1 NAME
Regexp::Ethiopic::Tigrigna - Regular Expressions Support for Tigrigna Language.
=head1 SYNOPSIS
#
# Overloading Perl REs:
#
use utf8;
use Regexp::Ethiopic::Tigrigna 'overload';
:
if ( /([=á =])áá[=á¸=][=á=]á/ ) {
#
# do something
#
:
}
:
:
#
# Without overloading:
#
use utf8;
require Regexp::Ethiopic::Tigrigna;
my $string = "([=á =])áá[=á¸=][=á=]á/";
my $re = Regexp::Ethiopic::Tigrigna::getRe ( $re );
s/abc($re)xyz/"abc".fixForm($1,6)."xyz"/eg;
=head1 DESCRIPTION
The Regexp::Ethiopic::Tigrigna module provides POSIX style character class
definitions for working with the localized use of Ethiopic syllabary in
the Tigrigna (ti) language. The character classes provided by the
Regexp::Ethiopic::Tigrigna package correspond to properties of the script
under Tigrigna orthography rules.
The Regexp::Ethiopic::Tigrigna uses Regexp::Ethiopic so generally you
would not need to import both. Regexp::Ethiopic::Tigrigna conditionally
exports the hashes %TigrignaEquivalence and %TigrignaClassEquivalence
should you wish to use them. Regexp::Ethiopic::Tigrigna can also
export %EthiopiClass of Regexp::Ethiopic:
use Regexp::Ethiopic::Tigrigna qw(%EthiopicClasses %TigrignaEquivalence %TigrignaClassEquivalence);
The Regexp::Ethiopic::Tigrigna package is NOT derived from the Regexp class
and may not be instantiated into an object. See the files in the
doc/ and examples/ directories that are included with this package.
=head1 REQUIRES
Works perfectly with Perl 5.8.0, may work with Perl 5.6.x but has
not yet been tested.
=head1 BUGS
None presently known.
=head1 AUTHOR
Daniel Yacob, L<dyacob@cpan.org|mailto:dyacob@cpan.org>
=cut