http://qs321.pair.com?node_id=665386


in reply to Similarity matrix

Maybe something like this? Assumes symmetry (d(x, y) = d(y, x)).
my @sim; my @words = ...; for my $i (0 .. $#words) { for my $j ( ($i+1) .. $#words) { $sim[$i][$j] = similarity( $words[$i], $words[$j]) $sim[$j][$i] = $sim[$i][$j]; } } sub similarity { my ( $w1, $w2 ) = @_; my $sim = 1; # calc simularity return sim; }

Replies are listed 'Best First'.
Re^2: Similarity matrix
by smilly (Novice) on Feb 01, 2008 at 23:07 UTC

    it's a good help friend, tx. just i have to more questions:
    1- how to read a corpus. (just normal open file can help me?)
    2- how to use a module with its parameters in my sub routines?(considering i want to use wordner::similarity module)
    tx alot for help.
Re^2: Similarity matrix
by Anonymous Monk on Feb 04, 2008 at 14:40 UTC
    Dear friend i could somehow figure it out but in $sim$j$i i get scalar found error saying: scalar found where operation expected... how can i figure it out?
      hey friends i fixed that:) just i dont know why i get readline() on closed filehandle FILE error... any idea?