Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #15: Added new file sentiment-analysis.js. Added dependencies #46

Merged
merged 7 commits into from
Nov 9, 2019
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"homepage": "https://github.com/Seneca-CDOT/telescope#readme",
"dependencies": {
"bent": "^7.0.2",
"bull": "^3.11.0"
"bull": "^3.11.0",
"sentiment": "^5.0.2"
},
"devDependencies": {
"eslint": "^6.6.0",
Expand Down
13 changes: 13 additions & 0 deletions src/sentiment-analysis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* This file contains the code for analyzing blog posts text to identify the
* negative or positve words being used in a post and return a summary of it
* along with a score. The file uses a node module called sentiment to implement
* the functionality of analyzing text of blogs. The function accepts plain
* text as a parameter i.e text containg no HTML tags, and returns a promise
* object whcih contains the result.
*/

module.exports.run = async function (text) {
const Sentiment = require('sentiment');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line needs to go above: we only want to require this once, not every call to run(). The next line, where you create an instance, is what I wanted in here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still not fixed. Move line 10 out of this function, and above like you had it before.

const sentiment = new Sentiment();
return Promise.resolve(sentiment.analyze(text));
};