开发者

Calculate Levenshtein Distances between many consecutive strings

开发者 https://www.devze.com 2023-01-31 02:14 出处:网络
I\'ve got a text file with str1 str2 str3... and I want to output another text file with LD(str1,str2) LD(str2,str3) LD(str3开发者_Go百科,str4) and so on. How to do this? Any language will do.#ASSUMIN

I've got a text file with str1 str2 str3... and I want to output another text file with LD(str1,str2) LD(str2,str3) LD(str3开发者_Go百科,str4) and so on. How to do this? Any language will do.


#ASSUMING YOUR RUNNIG SOME KIND OF UNIX
#install a perl module that computes it: 
sudo cpan String::Approx
# (Note: there is also Text::Levenshtein module)
# if you need to, change your shell to:
bash
# so you can use command substitution:
perl -M'String::Approx(adist)' -ane 'print adist(@F)' <(paste <(ghead -n -1 in.txt ) <(gtail -n +2 in.txt ))
# note: I have gnu core utils installed with 'g' prefix.  You might just use 'head' and 'tail' above.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号