From 2176073a841470ab1a0720e74d9b6a604d847e89 Mon Sep 17 00:00:00 2001 From: Jatin Arora Date: Tue, 5 Nov 2019 14:18:16 -0500 Subject: [PATCH 1/5] Fixes #15. Added new file sentiment-analysis.js. Added dependencies --- package-lock.json | 5 +++++ package.json | 3 ++- src/sentiment-analysis.js | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/sentiment-analysis.js diff --git a/package-lock.json b/package-lock.json index 8fd9f7aad2..407c46088e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -287,6 +287,11 @@ "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==" }, + "sentiment": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/sentiment/-/sentiment-5.0.2.tgz", + "integrity": "sha512-ZeC3y0JsOYTdwujt5uOd7ILJNilbgFzUtg/LEG4wUv43LayFNLZ28ec8+Su+h3saHlJmIwYxBzfDHHZuiMA15g==" + }, "standard-as-callback": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.0.1.tgz", diff --git a/package.json b/package.json index 096162ff76..02d0bb2cca 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/src/sentiment-analysis.js b/src/sentiment-analysis.js new file mode 100644 index 0000000000..b58da38fee --- /dev/null +++ b/src/sentiment-analysis.js @@ -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 + * HTML text as parameters i.e text containg no tags, and returns a promise + * object whcih contains the result +*/ + +var Sentiment = require('sentiment'); +var sentiment = new Sentiment(); + +module.exports.startAnalysys = function(blogText){ + var result; + return new Promise(function(resolve,reject){ + result = sentiment.analyze(blogText); + resolve(result); + }); +}; + From 259b31c11f926423304437065cecd538abd8b11e Mon Sep 17 00:00:00 2001 From: Jatin Arora Date: Wed, 6 Nov 2019 21:03:48 -0500 Subject: [PATCH 2/5] Fixed Typo in comments --- src/sentiment-analysis.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sentiment-analysis.js b/src/sentiment-analysis.js index b58da38fee..01504fe1e2 100644 --- a/src/sentiment-analysis.js +++ b/src/sentiment-analysis.js @@ -1,7 +1,7 @@ /* 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 + * the functionality of analyzing text of blogs. The function accepts stripped * HTML text as parameters i.e text containg no tags, and returns a promise * object whcih contains the result */ From be66e83fded0b3067216a533d2875777d9a3fb5c Mon Sep 17 00:00:00 2001 From: Jatin Arora Date: Wed, 6 Nov 2019 21:36:47 -0500 Subject: [PATCH 3/5] Update src/sentiment-analysis.js Adds async function. Co-Authored-By: David Humphrey --- src/sentiment-analysis.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sentiment-analysis.js b/src/sentiment-analysis.js index 01504fe1e2..2da8e3ed3e 100644 --- a/src/sentiment-analysis.js +++ b/src/sentiment-analysis.js @@ -9,7 +9,7 @@ var Sentiment = require('sentiment'); var sentiment = new Sentiment(); -module.exports.startAnalysys = function(blogText){ +module.exports.run = async function(text) { var result; return new Promise(function(resolve,reject){ result = sentiment.analyze(blogText); From 8ef394e1a14fa2d2522d8ed15b9d85de7a604cf3 Mon Sep 17 00:00:00 2001 From: Jatin Arora Date: Wed, 6 Nov 2019 21:46:27 -0500 Subject: [PATCH 4/5] Replaced var with const, updated function. --- src/sentiment-analysis.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/sentiment-analysis.js b/src/sentiment-analysis.js index 2da8e3ed3e..db5bfb41e9 100644 --- a/src/sentiment-analysis.js +++ b/src/sentiment-analysis.js @@ -1,19 +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 stripped - * HTML text as parameters i.e text containg no tags, and returns a promise - * object whcih contains the result + * 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. */ -var Sentiment = require('sentiment'); -var sentiment = new Sentiment(); - -module.exports.run = async function(text) { - var result; - return new Promise(function(resolve,reject){ - result = sentiment.analyze(blogText); - resolve(result); - }); +module.exports.run = async function (text) { + const Sentiment = require('sentiment'); + const sentiment = new Sentiment(); + return Promise.resolve(sentiment.analyze(text)); }; - From d07a3ac4104b391121be50e5feff7534e8f76f12 Mon Sep 17 00:00:00 2001 From: Jatin Arora Date: Fri, 8 Nov 2019 22:04:29 -0500 Subject: [PATCH 5/5] Updated sentiment-analysis.js --- src/sentiment-analysis.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sentiment-analysis.js b/src/sentiment-analysis.js index db5bfb41e9..85582364c3 100644 --- a/src/sentiment-analysis.js +++ b/src/sentiment-analysis.js @@ -5,9 +5,9 @@ * text as a parameter i.e text containg no HTML tags, and returns a promise * object whcih contains the result. */ +const Sentiment = require('sentiment'); module.exports.run = async function (text) { - const Sentiment = require('sentiment'); const sentiment = new Sentiment(); return Promise.resolve(sentiment.analyze(text)); };