From 714cef2680927b219c0bc3ce91334a883af8bc65 Mon Sep 17 00:00:00 2001 From: evenkeeler Date: Thu, 25 Aug 2016 00:01:20 -0400 Subject: [PATCH] (feat) Add naive sentiment output --- server/network/network.js | 6 +++++- server/routes.js | 4 ++++ server/sentimentRequestHandler.js | 19 +++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 server/sentimentRequestHandler.js diff --git a/server/network/network.js b/server/network/network.js index 7b57501..1f64943 100644 --- a/server/network/network.js +++ b/server/network/network.js @@ -87,7 +87,7 @@ var trainingSet = [ { input: [0,1,0,0,0,0,0,0,0,0,0,0,0,0], //rush output: [1,0,0,0,0,0,0] //stressed - } + }, { input: [1,0,0,0,0,0,0,0,0,0,0,0,0,0], //deadline output: [1,0,0,0,0,0,0] //stressed @@ -174,6 +174,10 @@ var moodTranslator = function(input){ console.log("mood translated is: " + moodTranslator(dailyMood)); var currentMood = moodTranslator(dailyMood) +module.exports = { + normWeeklyKeywords: normWeeklyKeywords +}; + //Input (keywords) // var wordNorm = { // love :[0,0,0,0,0,0,0,0,0,0,0,0,0,1], diff --git a/server/routes.js b/server/routes.js index 9da4446..9094bed 100644 --- a/server/routes.js +++ b/server/routes.js @@ -1,6 +1,7 @@ var requestHandler = require('./requestHandler.js'); var postRequestHandler = require('./postsRequestHandler.js'); var mixtapeRequestHandler = require('./request-handlers/mixtape.js'); +var sentimentRequestHandler = require('./sentimentRequestHandler.js'); module.exports = function (app, express){ app.get('/api/google/login', requestHandler.googleLogin); @@ -24,6 +25,9 @@ module.exports = function (app, express){ app.post('/api/soundcloud-search', mixtapeRequestHandler.searchSoundCloud); app.post('/api/delete-song', mixtapeRequestHandler.deleteSong); + /** sentiment **/ + app.get('/api/sentiment', sentimentRequestHandler.sendBackData); + //tester routes // app.post('/api/users', postRequestHandler.createUser); // app.put('/api/users', postRequestHandler.updateUser); diff --git a/server/sentimentRequestHandler.js b/server/sentimentRequestHandler.js new file mode 100644 index 0000000..a54ca33 --- /dev/null +++ b/server/sentimentRequestHandler.js @@ -0,0 +1,19 @@ +var normWeeklyKeywords = require('./network/network.js').normWeeklyKeywords; + +var dummyData = { + monday: ['ok', 'love', 'eager', 'fine', 'rush', 'hurray'], + tuesday: ['cry', 'sorry', 'sorry', 'frustrated', 'tired', 'tired', 'fine'], + wednesday: ['eager', 'fine', 'frustrated', 'fine', 'ok'], + thursday: ['eager', 'fine', 'rush', 'deadline', 'tired', 'ok', 'cry'], + friday: ['ok', 'cool', 'cool', 'relax', 'eager', 'good', 'love'], + saturday: ['love', 'love', 'eager', 'hurray', 'good', 'cool', 'fine'], + sunday: ['relax', 'cool', 'ok', 'fine', 'relax', 'tired', 'ok', 'hurray'] +} + + +exports.sendBackData = function(req, res, next){ + // console.log(normWeeklyKeywords(dummyData)); + console.log(normWeeklyKeywords(dummyData)); + res.status(200).send(normWeeklyKeywords(dummyData)); +} +