-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
940 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
temp | ||
temp.js | ||
*.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
// IntelliSense를 사용하여 가능한 특성에 대해 알아보세요. | ||
// 기존 특성에 대한 설명을 보려면 가리킵니다. | ||
// 자세한 내용을 보려면 https://go.microsoft.com/fwlink/?linkid=830387을(를) 방문하세요. | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "프로그램 시작", | ||
"program": "${file}" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const express = require('express'); | ||
const app = express(); | ||
const bodyParser=require('body-parser'); | ||
const busboy= require('busboy'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require('dotenv').config(); | ||
const rp = require("request-promise"); | ||
|
||
const URL = "http://aiopen.etri.re.kr:8000/"; | ||
const requestJson = { | ||
"request_id": "reserved field", | ||
"access_key": process.env.API_KEY, | ||
"argument": { | ||
} | ||
}; | ||
|
||
let apiConnect = {}; | ||
|
||
apiConnect.apiRequest=async(query,argument)=>{ | ||
|
||
return new Promise((resolve,reject)=>{ | ||
let reqJson = requestJson; | ||
reqJson.argument = argument; | ||
|
||
let option = { | ||
uri: URL+query, | ||
body: JSON.stringify(reqJson), | ||
headers: {'Content-Type':'application/json; charset=UTF-8'} | ||
} | ||
rp.post(option) | ||
.then((body)=>{ | ||
resolve(JSON.parse(body)); | ||
}) | ||
.catch((err)=>{ | ||
console.log("Http Request Error"); | ||
console.log(err.response.body); | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = apiConnect; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const express = require('express'); | ||
const app = express(); | ||
const bodyParser=require('body-parser'); | ||
const textAnalytic=require('./testAnalystic'); | ||
|
||
let cliConnection = {}; | ||
|
||
cliConnection.cliReq=(req,res)=>{ // 미완성 함수 | ||
let getData = JSON.parse(req.body.data); | ||
if(getData.type == ("text")){ | ||
textAnalytic(getData) | ||
.then() | ||
} | ||
}; | ||
|
||
//테스트용 지우지마 | ||
const run=async()=>{ | ||
let x = await textAnalytic({"text":"테스트용 문장입니다."}); | ||
console.log(x); | ||
} | ||
|
||
run(); | ||
module.exports=cliConnection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const express = require('express'); | ||
const app = express(); | ||
const bodyParser=require('body-parser'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const express=require('express'); | ||
const router=express.Router(); | ||
|
||
module.exports=router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const express = require('express'); | ||
const app = express(); | ||
const bodyParser=require('body-parser'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
const apiConnect = require('./apiConnect'); | ||
const search = require('./search'); | ||
|
||
const apiRequest= apiConnect.apiRequest; | ||
|
||
const wikiQA = "WikiQA"; | ||
const textMean = "WiseNLU"; | ||
const argumentWiki = { | ||
"question":"" , | ||
"type":"hybridqa"// 걍 통합한걸로 했는데 수정 | ||
} | ||
const argumnetMean = { | ||
"analysis_code": "", | ||
"text": "" | ||
} | ||
|
||
const mean=async(getData)=>{ | ||
return new Promise(async(resolve,reject)=>{ | ||
|
||
let tempMeanMorp = argumnetMean; | ||
tempMeanMorp.analysis_code = "morp"; | ||
tempMeanMorp.text = getData.text; | ||
|
||
let tempMeanSrl = argumnetMean; | ||
tempMeanSrl.analysis_code = "srl"; | ||
tempMeanSrl.text =getData.text; | ||
|
||
// 병렬처리 위해 | ||
let [morpResult,srlResult]=await Promise.all([apiRequest(textMean,tempMeanMorp),apiRequest(textMean,tempMeanSrl)]); | ||
|
||
resolve({"morp":morpResult,"srl":srlResult}); | ||
}); | ||
|
||
}; | ||
|
||
const textAnalystic=(getData)=>{ | ||
return new Promise(async(resolve,reject)=>{ | ||
let tempWiki = argumentWiki; | ||
tempWiki.question = getData.text; | ||
|
||
let [wikiResult,etcResult]=await Promise.all([apiRequest(wikiQA,tempWiki),mean(getData)]); //원래 mean 다음에 then(search); | ||
|
||
resolve({"wiki":wikiResult,"etc":etcResult}); | ||
}); | ||
|
||
} | ||
|
||
module.exports = textAnalystic; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const express = require('express'); | ||
const app = express(); | ||
const bodyParser=require('body-parser'); | ||
const fs= require('fs'); | ||
const morgan=require('morgan'); | ||
|
||
app.use(morgan('[:date[iso]] :method :status :url :response-time(ms) :user-agent')); | ||
app.use(bodyParser.urlencoded({ extended: true })); | ||
|
||
app.use('/api',require('./api')); | ||
|
||
app.listen(3000,()=>{ | ||
console.log('Server On!'); | ||
}); |
Oops, something went wrong.