Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replace SA module

  • Loading branch information...
commit 402cebee489daef2443826906b23134698fdfcf8 1 parent f07d591
@thisandagain authored
Showing with 15 additions and 16 deletions.
  1. +1 −2  README.md
  2. +11 −11 lib/index.js
  3. +3 −3 package.json
View
3  README.md
@@ -60,6 +60,5 @@ npm test
```
### Credits
-- Sentiment analysis using [AFINN](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6010) by [thinkroth](https://github.com/thinkroth)
-- Neural network by [harthur](https://github.com/harthur)
+- Neural network by [Heather Arthur](https://github.com/harthur)
- Training data inferred and subsequently condensed by scraping [Boing Boing's](http://boingboing.net) reader comments.
View
22 lib/index.js
@@ -8,10 +8,10 @@
/**
* Dependencies
*/
-var _ = require('underscore'),
+var _ = require('lodash'),
async = require('async'),
brain = require('brain'),
- sentimental = require('Sentimental'),
+ sentiment = require('sentiment'),
redis = require('redis');
var Adapter = require('./adapter'),
@@ -83,7 +83,6 @@ function Troll () {
// Setup
self.adapter = new Adapter(client);
- self.sentiment = sentimental.analyze;
self.net = new brain.NeuralNetwork();
};
@@ -105,14 +104,15 @@ Troll.prototype.analyze = function (input, user, callback) {
}
// Analyze input
- var result = self.sentiment(input).score;
-
- // Associate
- if (user === null) {
- callback(null, result);
- } else {
- self.adapter.push(user, result, callback);
- }
+ sentiment(input, function (err, result) {
+ if (err) return callback(err);
+
+ if (user === null) {
+ callback(null, result.score);
+ } else {
+ self.adapter.push(user, result.score, callback);
+ }
+ });
};
/**
View
6 package.json
@@ -14,10 +14,10 @@
},
"dependencies": {
"async": "~0.1.22",
- "underscore": "~1.4.1",
- "Sentimental": "0.0.2",
"redis": "~0.8.1",
- "brain": "~0.6.0"
+ "brain": "~0.6.0",
+ "sentiment": "~0.1.0",
+ "lodash": "~0.8.1"
},
"devDependencies": {
"tap": "~0.3.1",
Please sign in to comment.
Something went wrong with that request. Please try again.