-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
38 lines (37 loc) · 1.22 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module.exports = function (kathaa_inputs, progress, done){
////console.log("Inside ner");
//save computed output values
var kathaa_outputs = {}
hindi_urdu_request.post({
headers: {'content-type' : 'application/x-www-form-urlencoded;charset=UTF-8'},
url: 'http://api.ilmt.iiit.ac.in/hin/urd/9/9',
body: "input="+encodeURI(kathaa_inputs['in_ssf'])
}, function(error, response, body){
if (!error && response.statusCode == 200) {
try{
////console.log(body);
body = hindi_urdu_entities.decode(body);
body = JSON.parse(body);
//Assumes only one key is passed
for(var _key in body){
kathaa_outputs['out_ssf'] = body[_key];
done && done(null, kathaa_outputs);
return;
}
}catch(e){
var err = new Error('Malformed reply from Sampark API Server');
done(err);
}
}else{
var err = new Error('Sampark API Server non responsive');
done(err);
}
});
//
//
// Available external libraries
//
// GLOBAL.hindi_urdu_request = require('request');
// GLOBAL.hindi_urdu_Entities = require('html-entities').AllHtmlEntities;
// GLOBAL.hindi_urdu_entities = new GLOBAL.hindi_urdu_Entities();
}