$MI_T=MI($hypo,$text,\%hash_es,\%hash_en); sub MI { my ($string_es,$string_en,$hash_es,$hash_en)=@_; my @array_es= my @array_en = (); @array_es = split ' ', $hash_es{$string_es}; @array_en = split ' ', $hash_en{$string_en}; my $prob_es = ($#array_es+1)/6939873; my $prob_en = ($#array_en+1)/6939873; my $intersection= Intersection(\@array_es,\@array_en); my $prob_es_en= ($intersection)/6939873; $prob_es_en = ($prob_es_en + ($prob_es*$prob_en*0.1))/1.1; my $mi= $prob_es_en * log( $prob_es_en / ($prob_es * $prob_en) ); return $mi; } sub Intersection { my( $refA, $refB ) = @_; my %counts; ++$counts{ $_ } for @$refA; ++$counts{ $_ } for @$refB; my $intersects = 0; $counts{ $_ } > 1 and ++$intersects for keys %counts; return $intersects; }