Home  |  About Us  |  Link To Us  |  FAQ  |  Contact

# Text::WagnerFischer 0.04

Date Added: May 14, 2010  |  Visits: 578

Text::WagnerFischer is an implementation of the Wagner-Fischer edit distance. SYNOPSIS use Text::WagnerFischer qw(distance); print distance("foo","four");# prints "2" print distance([0,1,2],"foo","four");# prints "3" my @words=("four","foo","bar"); my @distances=distance("foo",@words); print "@distances"; # prints "2 0 3" @distances=distance([0,2,1],"foo",@words); print "@distances"; # prints "3 0 3" This module implements the Wagner-Fischer dynamic programming technique, used here to calculate the edit distance of two strings. The edit distance is a measure of the degree of proximity between two strings, based on "edits": the operations of substitutions, deletions or insertions needed to transform the string into the other one (and vice versa). A cost (weight) is needed for every of the operation defined above: / a if x=y (cost for letter match) w(x,y) = | b if x=- or y=- (cost for insertion/deletion operation) c if x!=y (cost for letter mismatch) These costs are given through an array reference as first argument of the distance subroutine: [a,b,c]. If the costs are not given, a default array cost is used: [0,1,1] that is the case of the Levenshtein edit distance: / 0 if x=y (cost for letter match) w(x,y) = | 1 if x=- or y=- (cost for insertion/deletion operation) 1 if x!=y (cost for letter mismatch) This particular distance is the exact number of edit needed to transform the string into the other one (and vice versa). 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..

 Requirements: No special requirements Platforms: Linux Keyword: Cost,  Distance,  Edit,  Foo,  Libraries,  Programming,  Textwagnerfischer,  Wagnerfischer Users rating: 0/10