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.