我有一个带str1 str2 str3的文本文件...我想用LD(str1,str2)LD(str2,str3)LD(str3,str4)输出另一个文本文件,依此类推。这该怎么做?任何语言都可以。
答案 0 :(得分:2)
#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.