Skip to content

Commit

Permalink
Ajusted to user LR algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
maiquelcraash committed Jun 5, 2018
1 parent 1d16124 commit c70e5b7
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 26 deletions.
5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

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

2 changes: 1 addition & 1 deletion config/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/* Classifier Config */
exports.EFFECTIVE_PERCENTUAL = 65; // Ponto de corte entre agressivo e não agressivo
exports.CLASSIFIER_ALGORITHM = "NB"; //"NB" (Nayve Bayes) or "LR" (Linear Regression)
exports.CLASSIFIER_ALGORITHM = "LR"; //"NB" (Nayve Bayes) or "LR" (Linear Regression)

if (process.env.NODE_ENV === "development") {
exports.CLASSIFIER_SERVER_PORT = 8082;
Expand Down
14 changes: 8 additions & 6 deletions controller/preProcessorController.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,21 @@
* Process individual texts
* @param text to processs
*/

let preProcessText = (text) => {
let processedText = text;

//removes trash
//Remove resíduos textuais como "ahuahua", "kkkk", "http", etc
processedText = removeTrashWords(processedText);

//removes symbols
//Remove simbolos e números
processedText = removeSymbols(processedText);

//remove the stopwords
processedText = removeIrrelevantWorlds(processedText);
// Efetua Análise Sintática e remove palavras sintaticamente
// irrelevantes para a detecção de emoções
processedText = removeIrrelevantWords(processedText);

//stemmer
//Análise Léxica, extração dos radicais
processedText = steemer(processedText);

return processedText;
Expand Down Expand Up @@ -134,7 +136,7 @@
* @param str - target string
* @returns {string} a new string without irrelevant words based on pt-br sintax rules
*/
function removeIrrelevantWorlds(str) {
function removeIrrelevantWords(str) {
let words = [];

let tags = posTaggerController.getPOSTags(str);
Expand Down
19 changes: 0 additions & 19 deletions main-services/server.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
/**
* Created by maiquel on 28/02/18.
*/

(function () {
"use strict";

const http = require('http'),
express = require('express'),
bodyParser = require('body-parser'),
properties = require('../config/properties'),
StringDecoder = require('string_decoder').StringDecoder, //módulo para decodificar strings
decoder = new StringDecoder('utf8');


let dir = __dirname.split("/");
dir.pop();
const root = dir.join("/");
Expand All @@ -31,7 +25,6 @@
app.use("/js", express.static(root + '/public/js'));
app.use("/img", express.static(root + '/public/img'));


app.server.listen(properties.WEB_SERVER_PORT);
console.log("Server started on port " + properties.WEB_SERVER_PORT);

Expand All @@ -50,11 +43,9 @@

app.post('/classify', (req, serverRes) => {
let target = req.body.target;

const postData = {
'target': target
};

let options = {
host: properties.CLASSIFIER_HOST,
port: properties.CLASSIFIER_SERVER_PORT,
Expand All @@ -68,12 +59,10 @@

const classifierRequest = http.request(options, (res) => {
const {statusCode} = res;

res.setEncoding('utf8');
res.on('data', (data) => {
serverRes.json(JSON.parse(data));
});

});

classifierRequest.on('error', (e) => {
Expand All @@ -85,15 +74,12 @@
serverRes.send(e.message);
}
});

classifierRequest.end(JSON.stringify(postData));

});

app.post('/feedback', (req, serverRes) => {
let activityID = req.body.activityID;
let feedback = req.body.feedback;

const postData = {
activityID: activityID,
feedback: feedback
Expand All @@ -112,12 +98,10 @@

const classifierRequest = http.request(options, (res) => {
const {statusCode} = res;

res.setEncoding('utf8');
res.on('data', (data) => {
serverRes.json(JSON.parse(data));
});

});

classifierRequest.on('error', (e) => {
Expand All @@ -129,9 +113,6 @@
serverRes.send(e.message);
}
});

classifierRequest.end(JSON.stringify(postData));

});

}());

0 comments on commit c70e5b7

Please sign in to comment.