NAME

Text::WagnerFischer::Amharic - The Wagner-Fischer Algorithm for Amharic.

SYNOPSIS

use utf8;
use Text::WagnerFischer::Amharic qw(distance);

# Calculate distance with the default penalty costs (weights):
print distance ( "ፀሐይ", "ጸሀይ" ), "\n";  # prints "2"

# Calcualte distance with a supplied costs array:
print distance ( [0,2,3, 1,2,1, 1,1,1, 1], "ፀሐይ", "ጸሀይ" ), "\n";  # prints "2"


# Calcualte distances between a word and a list of comparison words:

my @words = ( "ፀሐይ",  "ፀሓይ", "ፀሀይ", "ፀሃይ", "ጸሐይ", "ጸሓይ", "ጸሀይ", "ጸሃይ" );

my @distances = distance ( "ፀሐይ", @words );
print "@distances\n"; # prints "0 1 1 1 1 2 2 2"

@distances = distance ( [0,2,3, 1,1,1, 1,1,1, 2], "ፀሐይ", @words );
print "@distances\n"; # prints "0 1 1 2 1 2 2 3"

DESCRIPTION

This module implements the Wagner-Fischer edit distance algorithm for Ethiopic script under Amharic character classes.

The edit distance is a measure of the degree of proximity between two strings, based on "edits". Each type of edit is given its own cost (weight). In additional to the three initial Wagner-Fischer weights, the Amharic weight function recognizes 7 additional mismatch types:

           / a: x = y           (cost for letter match)
w(x,y) =  |  b: x = - or y = -  (cost for insertion/deletion operation)
          |  c: x != y          (cost for letter mismatch)
          |  x =~ [#y#] and
          |    d: x =~ [=y=]                  (cost of decayed labiovelar)
          |    e: form(x) > 7 || form(y) > 7  (cost of labiovelar mismatch)
          |    f: else                        (cost of wrong form)
          |  form(x) == form(y) and
          |    g: x =~ [=y=]                  (cost of grapheme mismatch)
          |    h: x is a shift-slip of y      (cost of shift key mismatch)
          |    i: else                        (cost of wrong base)
          \  j: x =~ [=y=]  (cost of wrong grapheme and form, right phoneme)

These costs are given through an array reference as an option first argument of the distance subroutine (see SYNOPSIS).

When two strings have distance 0, they are the same. Note that the distance is calculated to reach the _minimum_ cost, i.e. choosing the most economic operation for each edit.

BUGS

None presently known.

AUTHOR

Daniel Yacob, dyacob@cpan.org

LICENSE AND COPYRIGHT

Copyright (c) 2003-2025, Daniel Yacob <dyacob@cpan.org>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.

SEE ALSO

Text::WagnerFischer, Text::Metaphone::Amharic, Regexp::Ethiopic