NAME
Lingua::EN::Opinion - Measure the emotional sentiment of text
VERSION
version 0.0503
SYNOPSIS
use Lingua::EN::Opinion;
my $opinion = Lingua::EN::Opinion->new( file => '/some/file.txt' );
$opinion->analyze();
my $score = $opinion->averaged_score(5);
# OR
$opinion = Lingua::EN::Opinion->new( text => 'Mary had a little lamb...' );
$opinion->nrc_sentiment();
# And now do something cool with $opinion->nrc_scores...
DESCRIPTION
A Lingua::EN::Opinion
measures the emotional sentiment of text.
NOTE: This module is 3.4MB because of the GIANT sentiment text it comes with.
Please see the eg/ and t/ scripts for example usage.
The write-up illustrating usage and results can be found at http://techn.ology.net/book-of-revelation-sentiment-analysis/
ATTRIBUTES
file
The text file to analyze.
text
A text string to analyze instead of a text file.
sentences
Computed result.
scores
Computed result.
nrc_scores
Computed result.
METHODS
new()
$opinion = Lingua::EN::Opinion->new(%arguments);
Create a new Lingua::EN::Opinion
object.
analyze()
$opinion->analyze();
Measure the emotional sentiment of text. This method sets the scores and sentences attributes.
averaged_score()
$averaged = $opinion->averaged_score($bins);
Compute the averaged score given a number of (integer) bins (default: 10).
This reduces the amount of "noise" in the original signal. As such, it loses information detail.
For example, if there are 400 sentences, bins of 10 will result in 40 data points. Each point will be the mean of each successive bin-sized set of points in the analyzed score.
nrc_sentiment()
Compute the NRC sentiment of the given text by sentences.
This is given by a 0/1 list of these 10 emotional elements:
anger
anticipation
disgust
fear
joy
negative
positive
sadness
surprise
trust
This method sets the nrc_scores attribute.
SEE ALSO
https://www.cs.uic.edu/~liub/FBS/sentiment-analysis.html#lexicon
http://saifmohammad.com/WebPages/NRC-Emotion-Lexicon.htm
http://techn.ology.net/book-of-revelation-sentiment-analysis/
AUTHOR
Gene Boggs <gene@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2018 by Gene Boggs.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.