Showing
1 changed file
with
26 additions
and
0 deletions
... | @@ -75,4 +75,30 @@ apiRequest.Korean = async ( text ) => { | ... | @@ -75,4 +75,30 @@ apiRequest.Korean = async ( text ) => { |
75 | }); | 75 | }); |
76 | } | 76 | } |
77 | 77 | ||
78 | +const DOCVECAPI = (searchResults, keywordText, index) => { | ||
79 | + return new Promise((resolve, reject) => { | ||
80 | + apiReqOption = { | ||
81 | + method: "POST", | ||
82 | + uri: "http://127.0.0.1:5000/analyze", | ||
83 | + body: { | ||
84 | + sentence1: searchResults[index].passage, | ||
85 | + sentence2: keywordText | ||
86 | + }, | ||
87 | + json: true | ||
88 | + }; | ||
89 | + rp.post(apiReqOption) | ||
90 | + .then(body => { | ||
91 | + if (body.result == "-1") { | ||
92 | + throw new Error(body.data + " index : " + index); | ||
93 | + } | ||
94 | + searchResults[index].confidence = Number(body.result); | ||
95 | + resolve(); | ||
96 | + }) | ||
97 | + .catch(err => { | ||
98 | + searchResults[index].confidence = 0; | ||
99 | + resolve(); | ||
100 | + }); | ||
101 | + }); | ||
102 | + }; | ||
103 | + | ||
78 | module.exports = apiRequest; | 104 | module.exports = apiRequest; | ... | ... |
-
Please register or login to post a comment