2010-12-19 10 views
1

私はstr1 str2 str3でテキストファイルを持っています...そして、私はLD(str1、str2)を使って別のテキストファイルを出力したいと思います。LD(str2、str3)LD(str3、str4 ) 等々。これを行う方法?どんな言語でもできます。多くの連続した文字列間の距離を計算する

答えて

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. 
関連する問題