This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
vakavic.js
93 lines (77 loc) · 1.99 KB
/
vakavic.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
var request = require('request-promise-native');
module.exports = class Vakavic {
constructor(options) {
if (options.api_token == undefined) {
throw new Error(
'Vakavic API_TOKEN not initilized please log in to your vakavic account to obtain an API_TOKEN'
);
}
this.api_token = options.api_token;
this.api_url = 'https://api.vakavic.com';
this.header = {
'content-type': 'application/json',
Authorization: 'Bearer ' + this.api_token
};
this.sentenceCount = 5;
if (options.sentenceCount != undefined) {
this.sentenceCount = options.sentenceCount;
}
}
classify(module_key, text) {
let url = this.api_url + '/classifier/classify';
var options = {
headers: this.header,
uri: url,
method: 'POST',
rejectUnauthorized: false,
json: {
referenceKey: module_key,
text: text
}
};
return request(options);
}
getClassifications(module_key, text) {
let url = this.api_url + '/classifier/getClassifications';
var options = {
headers: this.header,
uri: url,
method: 'POST',
rejectUnauthorized: false,
json: {
referenceKey: module_key,
text: text
}
};
return request(options);
}
batchClassifications(module_key, data) {
let url = this.api_url + '/classifier/batchClassification';
var options = {
headers: this.header,
uri: url,
method: 'POST',
rejectUnauthorized: false,
json: {
referenceKey: module_key,
data: data
}
};
return request(options);
}
summarizeText(text, sentenceCount = null) {
let url = this.api_url + '/summarizer/summarizetext';
var options = {
headers: this.header,
uri: url,
method: 'POST',
rejectUnauthorized: false,
json: {
text: text,
sentenceCount:
sentenceCount == null ? this.sentenceCount : sentenceCount
}
};
return request(options);
}
};