ProductPromotion
Logo

Ruby

made by https://0x3d.site

GitHub - 7compass/sentimental: Simple sentiment analysis with Ruby
Simple sentiment analysis with Ruby. Contribute to 7compass/sentimental development by creating an account on GitHub.
Visit Site

GitHub - 7compass/sentimental: Simple sentiment analysis with Ruby

GitHub - 7compass/sentimental: Simple sentiment analysis with Ruby

sentimental

Simple sentiment analysis with Ruby

How it works

Sentences are tokenized and tokens are assigned a numerical score for their average sentiment. The total score is then used to determine the overall sentiment in relation to the threshold.

For example, the default threshold is 0.0. If a sentence has a score of 0, it is deemed "neutral". Higher than the thresold is "positive", lower is "negative".

If you set the threshold to a non-zero amount, e.g. 0.25:

  • Positive scores are > 0.25
  • Neutral scores are -0.25 - 0.25
  • Negative scores are < -0.25

Usage


# Create an instance for usage
analyzer = Sentimental.new

# Load the default sentiment dictionaries
analyzer.load_defaults

# And/or load your own dictionaries
analyzer.load_senti_file('path/to/your/file.txt')

# Set a global threshold
analyzer.threshold = 0.1

# Use your analyzer
analyzer.sentiment 'I love ruby'
#=> :positive

analyzer.sentiment 'I like ruby'
#=> :neutral

analyzer.sentiment 'I really like ruby'
#=> :positive

# You can make new analyzers with individual thresholds:
analyzer = Sentimental.new(threshold: 0.9)
analyzer.sentiment 'I love ruby'
#=> :positive

analyzer.sentiment 'I like ruby'
#=> :neutral

analyzer.sentiment 'I really like ruby'
#=> :neutral

# Get the numerical score of a string:
analyzer.score 'I love ruby'
#=> 0.925

Sentiment dictionaries

These are currently plain-text files containing whitespace-separated scores and tokens, e.g.:

1.0 Awesome
0.0 Meh
-1.0 Horrible

N-grams

You can parse n-grams of words by specifying their max size in the initializer:

  Sentimental.new(ngrams: 4)

The dictionary must have this format:

1.0 very happy
-2.0 no
0.0 meh

Installation

gem install sentimental

License

MIT License

Credits

Based largely on Christopher MacLellan's script: https://github.com/cmaclell/Basic-Tweet-Sentiment-Analyzer

Changes

  • 2013-10-13 Adding :-) to slang

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory