2

我有一个带有 str1 str2 str3... 的文本文件,我想用 LD(str1,str2) LD(str2,str3) LD(str3,str4) 等输出另一个文本文件。这个怎么做?任何语言都可以。

4

1 回答 1

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.
于 2010-12-19T08:33:41.560 回答