Thank you so much for your help!! I almost got the result I want. One last question, in my program, I have three categories which are positive, negative and neutral. I use this code to decide which categories a sentence belongs to
if ( $probability->{positive} > 1/3 ) { print "%positive:$sentence\n"; } if ( $probability->{negative} > 1/3 ) { print "%negative:$sentence\n"; } if ( $probability->{neutral} > 1/3 ) { print "%neutral:$sentence\n"; }
however, sometimes one sentence may belong to two category, for example, if the probability of positive is 0.34 and the probability of neutral is 0.35, then this sentence will belong to both positive and neutral. I wrote this code to try to solve this problem:
if( $probability->{positive} > $probability->{negative} > $probability +->{neutral}) { print"%positive:$sentence\n"; } if( $probability->{positive} > $probability->{neutral} > $probabil +ity->{negative}) { print"%positive:$sentence\n"; } if( $probability->{negative} > $probability->{positive} > $probabi +lity->{neutral}) { print"%negative:$sentence\n"; } if( $probability->{negative} > $probability->{neutral} > $probabil +ity->{positive}) { print"%negative:$sentence\n"; } if( $probability->{neutral} > $probability->{positive} > $probabil +ity->{negative}) { print"%positive:$sentence\n"; } if( $probability->{neutral} > $probability->{negative} > $probabil +ity->{positive}) { print"%positive:$sentence\n"; }
But, when I run my program, the error message is like this:

syntax error at calculation.pl line 61, near "} >" Execution of calculation.pl aborted due to compilation errors.

I do not know how to modify the code, can you help me to solve it. Thank you so much!!!

In reply to Re^10: how to use Algorithm::NaiveBayes module by agnes
in thread how to use Algorithm::NaiveBayes module by agnes

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.