in reply to Re^9: how to use Algorithm::NaiveBayes module
in thread how to use Algorithm::NaiveBayes module
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!!!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^11: how to use Algorithm::NaiveBayes module
by tangent (Parson) on Apr 29, 2014 at 04:45 UTC | |
by agnes (Novice) on Apr 29, 2014 at 15:40 UTC | |
by agnes (Novice) on Apr 30, 2014 at 04:45 UTC | |
by choroba (Cardinal) on Apr 30, 2014 at 07:43 UTC | |
by agnes (Novice) on Apr 30, 2014 at 13:58 UTC |