Skip to content

Commit 9a9abec

Browse files
committed
added mood inquirer
1 parent 03fedd2 commit 9a9abec

File tree

6 files changed

+136
-2459
lines changed

6 files changed

+136
-2459
lines changed

export/chat.txt

Lines changed: 0 additions & 2459 deletions
Large diffs are not rendered by default.

node_modules/fs/README.md

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/fs/package.json

Lines changed: 46 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"dependencies": {
2424
"chalk": "^2.3.2",
2525
"commander": "^2.15.0",
26+
"fs": "0.0.1-security",
2627
"inquirer": "^5.1.0",
2728
"ora": "^2.0.0"
2829
},

parse_feelings.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
'use strict';
2+
const chalk = require('chalk');
3+
var program = require('commander');
4+
var inquirer = require('inquirer');
5+
const ora = require('ora');
6+
var fs = require('fs');
7+
const spinner = ora('Loading unicorns').start();
8+
// @parseText read .txt file and converts it to a String
9+
function parseText(input) {
10+
var remaining = '';
11+
12+
13+
input.on('data', function(data) {
14+
remaining += data;
15+
16+
});
17+
18+
19+
input.on('end', function() {
20+
parse_feelings(remaining)
21+
});
22+
23+
}
24+
25+
function parse_feelings(data){
26+
var lines = data.split('\n');
27+
var questions = [];
28+
29+
30+
for(var i = 0;i < lines.length-1;i++){
31+
// get rid of \n from one text
32+
33+
var line = lines[i]
34+
if(line.trim() != ""){
35+
questions.push(
36+
{
37+
type: 'list',
38+
name: "mood"+i,
39+
message: line,
40+
41+
choices: [
42+
new inquirer.Separator(),
43+
{name:'positive',value :'1'},
44+
{name:'neutral',value :'0'},
45+
{name:'negative',value :'-1'},
46+
new inquirer.Separator()
47+
]
48+
}
49+
)
50+
}
51+
}
52+
53+
spinner.succeed("Loaded Chat")
54+
55+
inquirer.prompt(questions).then(answers => {
56+
console.log(answers);
57+
58+
59+
}).catch(function (error_render) {
60+
61+
console.log("error_render");
62+
callback(error_render);
63+
});
64+
65+
}
66+
67+
68+
// reads chat_full.txt into input
69+
// .txt file must be in the root path
70+
71+
var input = fs.createReadStream('export/chat.txt');
72+
73+
// parses Text with given input
74+
parseText(input);
75+

0 commit comments

Comments
 (0)