taegwon

app.js final

......@@ -3,16 +3,16 @@ var selected_food = '';
var located = '';
var count = 0;
var real_data = '';
var directory = [['food_division_txt_file/korean_food_final.txt','food_division_txt_file/chinese_food_final.txt','food_division_txt_file/japanese_food_final.txt','food_division_txt_file/western_food_final.txt','food_division_txt_file/etc_food_final.txt'],['food_division_txt_file/meat.txt','food_division_txt_file/fish.txt','food_division_txt_file/ect.txt','\0','\0'],['food_division_txt_file/spicy_food_final.txt','food_division_txt_file/not_spicy_food_final.txt','\0','\0','\0'],['food_division_txt_file/water.txt','food_division_txt_file/dry.txt','\0','\0','\0'],['food_division_txt_file/cold_food_final.txt','food_division_txt_file/hot_food_final.txt','\0','\0','\0']];
var directory = [['CHATBOT/food_division_txt_file/korean_food_final.txt','CHATBOT/food_division_txt_file/chinese_food_final.txt','CHATBOT/food_division_txt_file/japanese_food_final.txt','CHATBOT/food_division_txt_file/western_food_final.txt','CHATBOT/food_division_txt_file/etc_food_final.txt'],['CHATBOT/food_division_txt_file/meat.txt','CHATBOT/food_division_txt_file/fish.txt','CHATBOT/food_division_txt_file/ect.txt','\0','\0'],['CHATBOT/food_division_txt_file/spicy_food_final.txt','CHATBOT/food_division_txt_file/not_spicy_food_final.txt','\0','\0','\0'],['CHATBOT/food_division_txt_file/water.txt','CHATBOT/food_division_txt_file/dry.txt','\0','\0','\0'],['CHATBOT/food_division_txt_file/cold_food_final.txt','CHATBOT/food_division_txt_file/hot_food_final.txt','\0','\0','\0']];
var save_file_name = ['fin_1.txt','fin_2.txt','fin_3.txt','fin.txt'];
var choosen = new Array();
var express = require('express');
const request = require('request');
const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
const TOKEN = 'Ur8nbk2bQAc9KavLSSJv0uzlKWCxCBnOJOKyqbRS1mMHWgJlEOPfb7v+X1DDEHocUmhU7KnPFN+KHt5S3SYd5QmF42aTeQpW2gDVTjyqty1Tn+p6QqEhI/uSz659PBHwczEYn0Plx+akfCNHDPJRpAdB04t89/1O/w1cDnyilFU='
const PAPAGO_URL = 'https://openapi.naver.com/v1/papago/n2mt'
const PAPAGO_ID = '1Z83W3lUGLqnNbrDAk8A'
const PAPAGO_SECRET = 'oDlgYoi4LO'
const TOKEN = 'TOKEN'
const PAPAGO_URL = 'PAPAGO URL'
const PAPAGO_ID = 'PAPAGO ID'
const PAPAGO_SECRET = 'PAPAGO SECRET'
var fs = require('fs');
const path = require('path');
const HTTPS = require('https');
......@@ -156,7 +156,7 @@ async function start_msg(replyToken, message) {
'X-Naver-Client-Id': `${PAPAGO_ID}`,
'X-Naver-Client-Secret': `${PAPAGO_SECRET}`
},
body: 'source=en&target=ko&text=' + "Hi This is Menu recommend Chatbot! If you follow the instructions, I will recommend the menu. 진행하시겠습니까?(y/n)",
body: 'source=en&target=ko&text=' + "Hi! This is Menu recommend Chatbot! If you follow the instructions, I will recommend the menu. 진행하시겠습니까? (y/n)",
json: true
}, (error, response, body) => {
if (!error && response.statusCode == 200) {
......@@ -193,7 +193,7 @@ async function opt_1(replyToken, message) {
'X-Naver-Client-Id': `${PAPAGO_ID}`,
'X-Naver-Client-Secret': `${PAPAGO_SECRET}`
},
body: 'source=en&target=ko&text=' + "1.Korean cuisine 2.Chinese food 3.Japanese food 4.Western food 5.Guitar",
body: 'source=en&target=ko&text=' + "1.한식 2.중식 3.Japanese food 4.Western food 5.Guitar",
json: true
}, (error, response, body) => {
if (!error && response.statusCode == 200) {
......@@ -383,7 +383,7 @@ async function Rmx_comment(replyToken)
"messages": [
{
"type": "text",
"text": "아무키나 입력해 추천 음식 보기."
"text": "아무 키나 입력해 추천 음식 보기."
}
]
}
......@@ -560,7 +560,7 @@ async function intersection()
{
const spawn = await require('child_process').spawn;
for (var i = 0, j = 0; i < 3; i += 2, j++) {
var result = await spawn('python', ['fileread_practice.py', directory[i][Number(choosen[i]) - 1], directory[i + 1][Number(choosen[i + 1]) - 1], save_file_name[j]]);
var result = await spawn('python', ['/home/ec2-user/menu_recommand_webpage/CHATBOT/fileread_practice.py', directory[i][Number(choosen[i]) - 1], directory[i + 1][Number(choosen[i + 1]) - 1], save_file_name[j]]);
await result.stdout.on('data', function (data) {
console.log(data.toString());
});
......@@ -568,14 +568,14 @@ async function intersection()
console.log(data.toString());
});
}
result = await spawn('python', ['fileread_practice.py', save_file_name[0], save_file_name[1], save_file_name[2]]);
result = await spawn('python', ['/home/ec2-user/menu_recommand_webpage/CHATBOT/fileread_practice.py', save_file_name[0], save_file_name[1], save_file_name[2]]);
result.stdout.on('data', function (data) {
console.log(data.toString());
});
await result.stderr.on('data', function (data) {
console.log(data.toString());
});
result = await spawn('python', ['fileread_practice.py', save_file_name[2], directory[4][Number(choosen[4]) - 1], save_file_name[3]]);
result = await spawn('python', ['/home/ec2-user/menu_recommand_webpage/CHATBOT/fileread_practice.py', save_file_name[2], directory[4][Number(choosen[4]) - 1], save_file_name[3]]);
result.stdout.on('data', function (data) {
console.log(data.toString());
});
......