in reply to word based levenstein distance path

This thread may help you: Levenstein distance transcription
  • Comment on Re: word based levenstein distance path

Replies are listed 'Best First'.
Re^2: word based levenstein distance path
by Anonymous Monk on May 21, 2015 at 08:59 UTC

    Hi,

    Thanks for your reply.

    I have tried sdiff and it works fine. But given that I am new in perl, how can I print only the path? The output I am getting is:

    $VAR1 = [ [ '+', '', 'before' ], [ 'u', 'the', 'the' ], [ 'u', 'quick', 'quick' ], [ 'c', 'brown', 'green' ], [ 'u', 'fox', 'fox' ] ];

    What I need is:

    +uucu

    Any help would be greatly appreciated

      c:\@Work\Perl>perl -wMstrict -le "use constant PATH_ELEMENT => 0; ;; my @out = ( [ '+', '', 'before' ], [ 'u', 'the', 'the' ], [ 'u', 'quick', 'quick' ], [ 'c', 'brown', 'green' ], [ 'u', 'fox', 'fox' ], ); my $path = join '', map $_->[PATH_ELEMENT], @out; ;; $path eq '+uucu' or die qq{bad path: '$path'}; ;; print qq{proper path: '$path'}; " proper path: '+uucu'
      Update: Please see the constant pragma, and the join, map and die built-ins. (Update: See also the tutorial Map: The Basics and the subsidiary discussion of map in Complex sorting.)


      Give a man a fish:  <%-(-(-(-<

        Thanks, I have modified my code and it works!

        Once again thank you for your time and consideration