Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Similarity matrix

by smilly (Novice)
on Jan 30, 2008 at 23:32 UTC ( [id://665239]=perlquestion: print w/replies, xml ) Need Help??

smilly has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to build a similarity matrix to get my small corpus in input n get the similarity matrix(n by n, where n is the number of the words in the corpus) based on wordnet similarity (which is perl based itself). it means that the script get the words of the corpus and compare the similarity by using the external scripts and then the result is stored in a matrix. any one can kindly help me?

Replies are listed 'Best First'.
Re: Similarity matrix
by Khen1950fx (Canon) on Jan 31, 2008 at 01:30 UTC
      dear friend, Tx for ur reply, by similarity i mean semantic similarity, which i can use wordnet similarity of ted pederson..... im more specific how o use this into my scripts to build a matrix of similarities.....
Re: Similarity matrix
by InfiniteSilence (Curate) on Jan 31, 2008 at 01:00 UTC
    Try posting some actual code first.

    Celebrate Intellectual Diversity

Re: Similarity matrix
by lima1 (Curate) on Jan 31, 2008 at 16:53 UTC
    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; }
      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?

      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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://665239]
Approved by grep
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (8)
As of 2024-04-24 09:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found