Levenshtein距离是用于测量两个序列之间差异的字符串度量.Wagner-Fischer算法是一种动态编程算法,用于计算两个字符串之间的编辑距离.
两者都使用矩阵,我没有看到差异?这种差异是回溯还是由于一个是"文学"而另一个是编程这一事实没有进一步的区别?
另外,我只是写一篇论文,我不知道如何划分它 - 我是否应首先首先解释Levenshtein距离,然后再解释Wagner-Fisher算法或两者兼而有之?我在这里有点困惑.
algorithm edit-distance dynamic-programming levenshtein-distance
我想创建一个子程序,将元素(带有值的键)添加到先前定义的散列中.该子例程在循环中调用,因此哈希增长.我不希望返回的哈希覆盖现有元素.
最后,我想输出整个累积的哈希值.
现在它不打印任何东西.最终的哈希看起来是空的,但不应该.我已经尝试了哈希引用,但它并没有真正起作用.在简短的表单中,我的代码如下所示:
sub main{
my %hash;
%hash=("hello"=>1); # entry for testing
my $counter=0;
while($counter>5){
my(@var, $hash)=analyse($one, $two, \%hash);
print ref($hash);
# try to dereference the returning hash reference,
# but the error msg says: its not an reference ...
# in my file this is line 82
%hash=%{$hash};
$counter++;
}
# here trying to print the final hash
print "hash:", map { "$_ => $hash{$_}\n" } keys %hash;
}
sub analyse{
my $one=shift;
my $two=shift;
my %hash=%{shift @_};
my …Run Code Online (Sandbox Code Playgroud)