1
我有一個文本文件與str1 str2 str3 ...我想輸出另一個文本文件LD(str1,str2)LD(str2,str3)LD(str3,str4 ) 等等。這個怎麼做?任何語言都可以。計算Levenshtein許多連續字符串之間的距離
我有一個文本文件與str1 str2 str3 ...我想輸出另一個文本文件LD(str1,str2)LD(str2,str3)LD(str3,str4 ) 等等。這個怎麼做?任何語言都可以。計算Levenshtein許多連續字符串之間的距離
#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.