Hi everyone.
My question is the following. I have the following structure:

1 beast-n into transform-v 356.9551 2 beast-n obj kill-v 266.2511 3 beast-n obj see-v 252.3623 4 beast-n prd become-v 250.9534 5 beast-n obj tame-v 224.6948 6 beast-n into turn-v 191.9883 7 beast-n obj call-v 171.4000 8 beast-n sbj_intr devour-v 165.3228 9 beast-n obj hunt-v 155.7637 10 beast-n obj fight-v 150.4370 11 beast-n obj slay-v 150.3982 1 frog-n obj find-v 322.5589 2 frog-n into turn-v 307.3012 3 frog-n sbj_intr jump-v 235.0503 4 frog-n coord-1 toad-n 207.3611 5 frog-n obj see-v 207.2610 6 frog-n obj eat-v 204.1762 7 frog-n obj kill-v 64.6689

Using these data I need to implement a statistical measure to check the relevance of a given semantic relation in regards to the names it occur with.
Apart from the list above, I have two words as input. (sticking to the previous example, let's say they are beast-n and frog-n. If a given feature occurring with the first word also occurs whit the second, I have to compute Precision of the feature in regard to the first word. If I am at rank 1, and I found a feature that occurs also with the second word, my precision is 1, because it's computed as found_relevant_feat/rank_found. In the example above, the only feat that occurs both with beast and frog is kill-v. My precision would then be 1(which is the number of found_rel_feat until that rank)/2 which is the rank in which it occurs.
Also, I have to found the rank in which the given feature has been founded with word2. (in this case 7) When I am done with this I also need to know the total number of occurrence of the first word and the total number of occurrence of the second word. (given the example before, it would be 11 for beast-n and 7 for frog-n).

my ($prop,$rank, $score); my ($prop2,$rank2, $score2); while (my($name1,$aref) = each %matrice ) { my $num=0; foreach my $item (@$aref){ $count_feat_trovate=0; ($prop,$rank, $score) = split(',',$item); my $lastrank=&lastrank2($name2,$prop); while (my($name2,$aref2) = each %matrice) { foreach my $item1 (@$aref2){ ($prop2,$rank2, $score2) = split(',',$item1); if($prop eq $prop2){ $count_feat_trovate++; #number of feat found $rank_trovato_2=$rank2; #Rank of which the feat has been f +ound in regards to the second element } } } $last_rank_2=$rank2; } $last_rank_1=$rank; }

I guess I just made a lot of mess without achieving anything. Any ideas on how to retrieve the needed data?
Thanks
Giulia


In reply to Nested Cycle - Statistic measure by remluvr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.