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 1 commit
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 @@ -14,6 +14,7 @@
"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"
}
}
19 changes: 19 additions & 0 deletions src/sentiment-analysis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* 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 striped
Copy link
Contributor

@Immutablevoid Immutablevoid Nov 6, 2019

Choose a reason for hiding this comment

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

Typo on line 4: "The function accepts striped" should be "The function accepts stripped"
Otherwise looks good 👍 , need to rebase to match the current master branch.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @ImmutableBox ,
Resolved this in commit 259b31c

* HTML text as parameters i.e text containg no tags, and returns a promise
Copy link
Contributor

Choose a reason for hiding this comment

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

What does "stripped HTML" mean? Do you want plain text or HTML? If the former, I'd say that instead.

* object whcih contains the result
*/

var 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.

Prefer const to var

var sentiment = new Sentiment();
Copy link
Contributor

Choose a reason for hiding this comment

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

Prefer const here too, and also, let's move this into your function below so we don't reuse this between runs. If there's any shared state between runs, we'll get into weird bugs.


module.exports.startAnalysys = function(blogText){
jatinAroraGit marked this conversation as resolved.
Show resolved Hide resolved
var result;
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be simplified bit:

return Promise.resolve(sentiment.analyze(text));

Since this call doesn't throw, we just need to wrap it in a call to resolve

return new Promise(function(resolve,reject){
result = sentiment.analyze(blogText);
resolve(result);
});
};