| Lingua-AM-Abbreviate documentation | Contained in the Lingua-AM-Abbreviate distribution. |
AM::Abbreviate - Expand or Contract Amharic Abbreviations
use Lingua::AM::Abbreviate;
while ( $string = <> ) { # some UTF8 string
if ( $contracted = Contract ( $string ) ) {
print "$string => $contracted\n";
} elsif ( $expanded = Expand ( $string ) ) {
print "$string => $expanded\n";
}
}
AM::Abbreviate provides two routines, "Expand" and "Contract", to assist in Amharic translation or spell checking. Each routine expects an Amharic string in UTF8 encoding as an argument and returns an expansion or contraction if found.
Daniel Yacob, LibEth@EthiopiaOnline.Net
perl(1). Ethiopic(3), http://libeth.netpedia.net
| Lingua-AM-Abbreviate documentation | Contained in the Lingua-AM-Abbreviate distribution. |
package Lingua::AM::Abbreviate; require 5.000; require Exporter; @ISA = qw(Exporter); @EXPORT = qw( Contract Expand ); $VERSION = '0.01'; %AbbreviatedAmharic = ( 'áµ/á¤áµ' => 'áµáá ááµ á¤áµ', 'á½/á¤áµ' => 'á½á ááµ á¤áµ', 'á/á¤áµ' => 'ááá á¤áµ', 'á/á¤áµ' => 'áá¥áªá« á¤áµ', 'á/á¤áµ' => 'áááµ á¤áµ', 'á /áá´á¬á½á' => 'á á«á°á áá´á¬á½á', 'á¤/á' => 'á¤á°áááµáµá«á', 'á¤/á' => 'á¤á°ááááµáµ', 'á/á ' => 'áá¸áá á á±áµ', 'á/' => 'áááµá', 'á/' => 'áá¥á¨', 'á/' => 'ááá°', 'á°/' => 'á°áá', # ááá á°áµá 'á/' => 'ááá', 'á®/á' => 'á®ááá', 'á/á' => 'ááá«á', 'á»/' => 'á»áá á', 'á/á®' => 'áááá®', 'á/áªáµ' => 'ááááªáµ', 'á/á' => 'ááµá°á', 'á/áµ' => 'ááµáµ', 'á/á' => 'áá®áá°á', 'á/áµ' => 'áá¬áá³ááµ', 'á /á' => 'á á áá áááµáµá', 'á /áááµáµá' => 'á á áá áááµáµá', 'á /á/á¢á®' => 'á á áá áááµáµá á¢á®', 'á/á©' => 'áááµáµá©', 'á/á' => 'ááá° áá á¨áµ', 'á/á' => 'ááá° ááá', 'á /á ' => 'á á²áµ á á£á£', 'á¶/á' => 'á¶áá°á', 'á/á' => 'ááµáá³á' ); sub Expand { local ($term) = $_[0]; if ( $AbbreviatedAmharic{$term} ) { return ( $AbbreviatedAmharic{$term} ); } else { $prefix = $term =~ s/^([áá á¨á¨])//; if ( $AbbreviatedAmharic{$term} ) { return ( "$prefix$AbbreviatedAmharic{$term}" ); } else { $term = $_[0]; ($prefix, $term) = split ( /\//, $term, 2 ); $prefix .= "/"; if ( $AbbreviatedAmharic{$prefix} ) { return ( "$AbbreviatedAmharic{$prefix}$term" ); } } } } sub Contract { local ($term) = shift; foreach $key (keys %AbbreviatedAmharic) { return ( $key ) if ( $AbbreviatedAmharic{$key} eq $term ); # print "Contract: $AbbreviatedAmharic{$key} = $term\n"; if ( $term =~ /^$AbbreviatedAmharic{$key}/ ) { $term =~ s/$AbbreviatedAmharic{$key}//; return ( "$key$term" ); } } } # # ma/bEt # d/bEt # me/`se/ma # qe/ge/ma # m/wana as in "m/wana SeHefi" ######################################################### # Do not change this, Do not put anything below this. # File must return "true" value at termination 1; ########################################################## __END__