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} > 1/3 ) { print "%positive:$sentence\n"; } if ( $probability->{negative} > 1/3 ) { print "%negative:$sentence\n"; } if ( $probability->{neutral} > 1/3 ) { print "%neutral:$sentence\n"; }
But, when I run my program, the error message is like this: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"; }
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |