eventregistry 8.11.2 → 9.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics.d.ts +82 -82
- package/dist/analytics.js +336 -330
- package/dist/analytics.js.map +1 -1
- package/dist/base.d.ts +82 -81
- package/dist/base.js +261 -219
- package/dist/base.js.map +1 -1
- package/dist/counts.d.ts +81 -81
- package/dist/counts.js +162 -149
- package/dist/counts.js.map +1 -1
- package/dist/dailyShares.d.ts +10 -10
- package/dist/dailyShares.js +90 -77
- package/dist/dailyShares.js.map +1 -1
- package/dist/data.d.ts +269 -268
- package/dist/data.js +3 -3
- package/dist/eventForText.d.ts +48 -48
- package/dist/eventForText.js +126 -123
- package/dist/eventForText.js.map +1 -1
- package/dist/eventRegistry.d.ts +244 -224
- package/dist/eventRegistry.js +1098 -1018
- package/dist/eventRegistry.js.map +1 -1
- package/dist/index.d.ts +21 -20
- package/dist/index.js +128 -122
- package/dist/index.js.map +1 -1
- package/dist/info.d.ts +61 -61
- package/dist/info.js +171 -158
- package/dist/info.js.map +1 -1
- package/dist/logger.d.ts +44 -0
- package/dist/logger.js +144 -0
- package/dist/logger.js.map +1 -0
- package/dist/query.d.ts +53 -53
- package/dist/query.js +333 -290
- package/dist/query.js.map +1 -1
- package/dist/queryArticle.d.ts +61 -61
- package/dist/queryArticle.js +183 -168
- package/dist/queryArticle.js.map +1 -1
- package/dist/queryArticles.d.ts +144 -160
- package/dist/queryArticles.js +729 -701
- package/dist/queryArticles.js.map +1 -1
- package/dist/queryEvent.d.ts +140 -140
- package/dist/queryEvent.js +587 -569
- package/dist/queryEvent.js.map +1 -1
- package/dist/queryEvents.d.ts +210 -210
- package/dist/queryEvents.js +825 -798
- package/dist/queryEvents.js.map +1 -1
- package/dist/queryMentions.d.ts +96 -96
- package/dist/queryMentions.js +637 -600
- package/dist/queryMentions.js.map +1 -1
- package/dist/queryStory.d.ts +58 -58
- package/dist/queryStory.js +194 -174
- package/dist/queryStory.js.map +1 -1
- package/dist/recent.d.ts +23 -23
- package/dist/recent.js +199 -179
- package/dist/recent.js.map +1 -1
- package/dist/returnInfo.d.ts +68 -66
- package/dist/returnInfo.js +332 -304
- package/dist/returnInfo.js.map +1 -1
- package/dist/topicPage.d.ts +157 -157
- package/dist/topicPage.js +599 -604
- package/dist/topicPage.js.map +1 -1
- package/dist/trends.d.ts +35 -35
- package/dist/trends.js +115 -102
- package/dist/trends.js.map +1 -1
- package/dist/types.d.ts +2453 -2155
- package/dist/types.js +2 -2
- package/package.json +13 -13
package/dist/analytics.js
CHANGED
|
@@ -1,331 +1,337 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
function
|
|
17
|
-
function
|
|
18
|
-
step(
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
function step(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
case
|
|
33
|
-
case
|
|
34
|
-
case
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (
|
|
38
|
-
if (op[0] ===
|
|
39
|
-
if (
|
|
40
|
-
if (t[2]) _.ops.
|
|
41
|
-
_.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
//
|
|
52
|
-
//
|
|
53
|
-
// - text
|
|
54
|
-
//
|
|
55
|
-
//
|
|
56
|
-
// -
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
*
|
|
68
|
-
* @param
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
return [4 /*yield*/, this.er.jsonRequestAnalytics("/api/v1/annotate", params)];
|
|
82
|
-
case 1:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
case 1:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
*
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
case
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
case
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
*
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.Analytics = void 0;
|
|
51
|
+
// The Analytics class can be used for access the text analytics services provided by the Event Registry.
|
|
52
|
+
// These include:
|
|
53
|
+
// - text annotation: identifying the list of entities and non-entities mentioned in the provided text
|
|
54
|
+
// - text categorization: identification of up to 5 categories that describe the topic of the given text.
|
|
55
|
+
// The list of available categories come from DMOZ open directory. Currently, only English text can be categorized!
|
|
56
|
+
// - sentiment detection: what is the sentiment expressed in the given text
|
|
57
|
+
// - language detection: detect in which language is the given text written
|
|
58
|
+
// NOTE: the functionality is currently in BETA. The API calls or the provided outputs may change in the future.
|
|
59
|
+
var Analytics = /** @class */ (function () {
|
|
60
|
+
/**
|
|
61
|
+
* @param eventRegistry: instance of EventRegistry class
|
|
62
|
+
*/
|
|
63
|
+
function Analytics(er) {
|
|
64
|
+
this.er = er;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Identify the list of entities and nonentities mentioned in the text
|
|
68
|
+
* @param text input text to annotate
|
|
69
|
+
* @param lang language of the provided document (can be an ISO2 or ISO3 code). If None is provided, the language will be automatically detected
|
|
70
|
+
*/
|
|
71
|
+
Analytics.prototype.annotate = function (text, lang, customParams) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
73
|
+
var params, response;
|
|
74
|
+
return __generator(this, function (_a) {
|
|
75
|
+
switch (_a.label) {
|
|
76
|
+
case 0:
|
|
77
|
+
params = { lang: lang, text: text };
|
|
78
|
+
if (!!customParams) {
|
|
79
|
+
params = __assign(__assign({}, params), customParams);
|
|
80
|
+
}
|
|
81
|
+
return [4 /*yield*/, this.er.jsonRequestAnalytics("/api/v1/annotate", params)];
|
|
82
|
+
case 1:
|
|
83
|
+
response = _a.sent();
|
|
84
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.data];
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Determine the set of up to 5 categories the text is about. Currently, only English text can be categorized!
|
|
91
|
+
* @param text input text to categorize
|
|
92
|
+
* @param taxonomy: which taxonomy use for categorization. Options:
|
|
93
|
+
* - "dmoz" (over 5000 categories in 3 levels, English language only)
|
|
94
|
+
* - "news" (general news categorization, 9 categories, any langauge)
|
|
95
|
+
*/
|
|
96
|
+
Analytics.prototype.categorize = function (text_1) {
|
|
97
|
+
return __awaiter(this, arguments, void 0, function (text, taxonomy) {
|
|
98
|
+
var response;
|
|
99
|
+
if (taxonomy === void 0) { taxonomy = "dmoz"; }
|
|
100
|
+
return __generator(this, function (_a) {
|
|
101
|
+
switch (_a.label) {
|
|
102
|
+
case 0: return [4 /*yield*/, this.er.jsonRequestAnalytics("/api/v1/categorize", { text: text, taxonomy: taxonomy })];
|
|
103
|
+
case 1:
|
|
104
|
+
response = _a.sent();
|
|
105
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.data];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* determine the sentiment of the provided text in English language
|
|
112
|
+
* @param text input text to categorize
|
|
113
|
+
* @param method method to use to compute the sentiment. possible values are "vocabulary" (vocabulary based sentiment analysis) and "rnn" (neural network based sentiment classification)
|
|
114
|
+
*/
|
|
115
|
+
Analytics.prototype.sentiment = function (text_1) {
|
|
116
|
+
return __awaiter(this, arguments, void 0, function (text, method, sentences, returnSentences) {
|
|
117
|
+
var params, response;
|
|
118
|
+
if (method === void 0) { method = "vocabulary"; }
|
|
119
|
+
if (sentences === void 0) { sentences = 10; }
|
|
120
|
+
if (returnSentences === void 0) { returnSentences = true; }
|
|
121
|
+
return __generator(this, function (_a) {
|
|
122
|
+
switch (_a.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
if (!["vocabulary", "rnn"].includes(method)) {
|
|
125
|
+
throw new Error("method: Please pass in either 'vocabulary' or 'rnn'");
|
|
126
|
+
}
|
|
127
|
+
params = {
|
|
128
|
+
text: text,
|
|
129
|
+
method: method,
|
|
130
|
+
sentences: sentences,
|
|
131
|
+
returnSentences: returnSentences,
|
|
132
|
+
};
|
|
133
|
+
return [4 /*yield*/, this.er.jsonRequestAnalytics("/api/v1/sentiment", params)];
|
|
134
|
+
case 1:
|
|
135
|
+
response = _a.sent();
|
|
136
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.data];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
Analytics.prototype.semanticSimilarity = function (text1_1, text2_1) {
|
|
142
|
+
return __awaiter(this, arguments, void 0, function (text1, text2, distanceMeasure) {
|
|
143
|
+
var response;
|
|
144
|
+
if (distanceMeasure === void 0) { distanceMeasure = "cosine"; }
|
|
145
|
+
return __generator(this, function (_a) {
|
|
146
|
+
switch (_a.label) {
|
|
147
|
+
case 0: return [4 /*yield*/, this.er.jsonRequestAnalytics("/api/v1/semanticSimilarity", { text1: text1, text2: text2, distanceMeasure: distanceMeasure })];
|
|
148
|
+
case 1:
|
|
149
|
+
response = _a.sent();
|
|
150
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.data];
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
/**
|
|
156
|
+
* Determine the language of the given text
|
|
157
|
+
* @param text input text to analyse
|
|
158
|
+
*/
|
|
159
|
+
Analytics.prototype.detectLanguage = function (text) {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
161
|
+
var response;
|
|
162
|
+
return __generator(this, function (_a) {
|
|
163
|
+
switch (_a.label) {
|
|
164
|
+
case 0: return [4 /*yield*/, this.er.jsonRequestAnalytics("/api/v1/detectLanguage", { text: text })];
|
|
165
|
+
case 1:
|
|
166
|
+
response = _a.sent();
|
|
167
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.data];
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Extract all available information about an article available at url `url`.
|
|
174
|
+
* Returned information will include article title, body, authors, links in the articles,...
|
|
175
|
+
* @param url article url that'll be used for extraction
|
|
176
|
+
* @param proxyUrl proxy that should be used for downloading article information. format: {schema}://{username}:{pass}@{proxy url/ip}
|
|
177
|
+
*/
|
|
178
|
+
Analytics.prototype.extractArticleInfo = function (url, proxyUrl, headers, cookies) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
180
|
+
var params, response;
|
|
181
|
+
return __generator(this, function (_a) {
|
|
182
|
+
switch (_a.label) {
|
|
183
|
+
case 0:
|
|
184
|
+
params = { url: url };
|
|
185
|
+
if (!!proxyUrl) {
|
|
186
|
+
params.proxyUrl = proxyUrl;
|
|
187
|
+
}
|
|
188
|
+
return [4 /*yield*/, this.er.jsonRequestAnalytics("/api/v1/extractArticleInfo", params, headers, cookies)];
|
|
189
|
+
case 1:
|
|
190
|
+
response = _a.sent();
|
|
191
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.data];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Extract named entities from the provided text. Supported languages are English, German, Spanish and Chinese.
|
|
198
|
+
* @param text: text on which to extract named entities
|
|
199
|
+
*/
|
|
200
|
+
Analytics.prototype.ner = function (text) {
|
|
201
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
202
|
+
var response;
|
|
203
|
+
return __generator(this, function (_a) {
|
|
204
|
+
switch (_a.label) {
|
|
205
|
+
case 0: return [4 /*yield*/, this.er.jsonRequestAnalytics("/api/v1/ner", { text: text })];
|
|
206
|
+
case 1:
|
|
207
|
+
response = _a.sent();
|
|
208
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.data];
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Create a new topic and train it using the tweets that match the twitterQuery
|
|
215
|
+
* @param twitterQuery string containing the content to search for. It can be a Twitter user account (using "@" prefix or user's Twitter url),a hash tag (using "#" prefix) or a regular keyword.
|
|
216
|
+
* @param args Object which contains a host of optional parameters
|
|
217
|
+
*/
|
|
218
|
+
Analytics.prototype.trainTopicOnTweets = function (twitterQuery_1) {
|
|
219
|
+
return __awaiter(this, arguments, void 0, function (twitterQuery, args) {
|
|
220
|
+
var _a, useTweetText, _b, useIdfNormalization, _c, normalization, _d, maxTweets, _e, maxUsedLinks, _f, ignoreConceptTypes, _g, maxConcepts, _h, maxCategories, _j, notifyEmailAddress, params, response;
|
|
221
|
+
if (args === void 0) { args = {}; }
|
|
222
|
+
return __generator(this, function (_k) {
|
|
223
|
+
switch (_k.label) {
|
|
224
|
+
case 0:
|
|
225
|
+
_a = args.useTweetText, useTweetText = _a === void 0 ? true : _a, _b = args.useIdfNormalization, useIdfNormalization = _b === void 0 ? true : _b, _c = args.normalization, normalization = _c === void 0 ? "linear" : _c, _d = args.maxTweets, maxTweets = _d === void 0 ? 2000 : _d, _e = args.maxUsedLinks, maxUsedLinks = _e === void 0 ? 500 : _e, _f = args.ignoreConceptTypes, ignoreConceptTypes = _f === void 0 ? [] : _f, _g = args.maxConcepts, maxConcepts = _g === void 0 ? 20 : _g, _h = args.maxCategories, maxCategories = _h === void 0 ? 10 : _h, _j = args.notifyEmailAddress, notifyEmailAddress = _j === void 0 ? undefined : _j;
|
|
226
|
+
if (maxTweets > 5000) {
|
|
227
|
+
throw new Error("We can analyze at most 5000 tweets");
|
|
228
|
+
}
|
|
229
|
+
params = {
|
|
230
|
+
twitterQuery: twitterQuery,
|
|
231
|
+
useTweetText: useTweetText,
|
|
232
|
+
useIdfNormalization: useIdfNormalization,
|
|
233
|
+
normalization: normalization,
|
|
234
|
+
maxTweets: maxTweets,
|
|
235
|
+
maxUsedLinks: maxUsedLinks,
|
|
236
|
+
maxConcepts: maxConcepts,
|
|
237
|
+
maxCategories: maxCategories,
|
|
238
|
+
};
|
|
239
|
+
if (notifyEmailAddress) {
|
|
240
|
+
params.notifyEmailAddress = notifyEmailAddress;
|
|
241
|
+
}
|
|
242
|
+
if (ignoreConceptTypes && Object.keys(ignoreConceptTypes).length > 0) {
|
|
243
|
+
params.ignoreConceptTypes = ignoreConceptTypes;
|
|
244
|
+
}
|
|
245
|
+
return [4 /*yield*/, this.er.jsonRequestAnalytics("/api/v1/trainTopicOnTwitter", params)];
|
|
246
|
+
case 1:
|
|
247
|
+
response = _k.sent();
|
|
248
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.data];
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Create a new topic to train. The user should remember the "uri" parameter returned in the result.
|
|
255
|
+
* @param name name of the topic we want to create
|
|
256
|
+
* @returns object containing the "uri" property that should be used in the follow-up call to trainTopic* methods
|
|
257
|
+
*/
|
|
258
|
+
Analytics.prototype.trainTopicCreateTopic = function (name) {
|
|
259
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
260
|
+
var response;
|
|
261
|
+
return __generator(this, function (_a) {
|
|
262
|
+
switch (_a.label) {
|
|
263
|
+
case 0: return [4 /*yield*/, this.er.jsonRequestAnalytics("/api/v1/trainTopic", { action: "createTopic", name: name })];
|
|
264
|
+
case 1:
|
|
265
|
+
response = _a.sent();
|
|
266
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.data];
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* If the topic is already existing, clear the definition of the topic. Use this if you want to retrain an existing topic
|
|
273
|
+
* @param uri uri of the topic (obtained by calling trainTopicCreateTopic method) to clear
|
|
274
|
+
*/
|
|
275
|
+
Analytics.prototype.trainTopicClearTopic = function (uri) {
|
|
276
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
277
|
+
var response;
|
|
278
|
+
return __generator(this, function (_a) {
|
|
279
|
+
switch (_a.label) {
|
|
280
|
+
case 0: return [4 /*yield*/, this.er.jsonRequestAnalytics("/api/v1/trainTopic", { action: "clearTopic", uri: uri })];
|
|
281
|
+
case 1:
|
|
282
|
+
response = _a.sent();
|
|
283
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.data];
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
});
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* Add the information extracted from the provided "text" to the topic with uri "uri".
|
|
290
|
+
* @param uri uri of the topic (obtained by calling trainTopicCreateTopic method)
|
|
291
|
+
* @param text text to analyze and extract information from
|
|
292
|
+
*/
|
|
293
|
+
Analytics.prototype.trainTopicAddDocument = function (uri, text) {
|
|
294
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
295
|
+
var response;
|
|
296
|
+
return __generator(this, function (_a) {
|
|
297
|
+
switch (_a.label) {
|
|
298
|
+
case 0: return [4 /*yield*/, this.er.jsonRequestAnalytics("/api/v1/trainTopic", { action: "addDocument", uri: uri, text: text })];
|
|
299
|
+
case 1:
|
|
300
|
+
response = _a.sent();
|
|
301
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.data];
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* Retrieve topic for the topic for which you have already finished training
|
|
308
|
+
* @param uri uri of the topic (obtained by calling trainTopicCreateTopic method)
|
|
309
|
+
* @returns returns the trained topic: { concepts: [], categories: [] }
|
|
310
|
+
*/
|
|
311
|
+
Analytics.prototype.trainTopicGetTrainedTopic = function (uri_1) {
|
|
312
|
+
return __awaiter(this, arguments, void 0, function (uri, args) {
|
|
313
|
+
var _a, maxConcepts, _b, maxCategories, _c, idfNormalization, params, response;
|
|
314
|
+
if (args === void 0) { args = {}; }
|
|
315
|
+
return __generator(this, function (_d) {
|
|
316
|
+
switch (_d.label) {
|
|
317
|
+
case 0:
|
|
318
|
+
_a = args.maxConcepts, maxConcepts = _a === void 0 ? 20 : _a, _b = args.maxCategories, maxCategories = _b === void 0 ? 10 : _b, _c = args.idfNormalization, idfNormalization = _c === void 0 ? true : _c;
|
|
319
|
+
params = {
|
|
320
|
+
action: "getTrainedTopic",
|
|
321
|
+
uri: uri,
|
|
322
|
+
maxConcepts: maxConcepts,
|
|
323
|
+
maxCategories: maxCategories,
|
|
324
|
+
idfNormalization: idfNormalization,
|
|
325
|
+
};
|
|
326
|
+
return [4 /*yield*/, this.er.jsonRequestAnalytics("/api/v1/trainTopic", params)];
|
|
327
|
+
case 1:
|
|
328
|
+
response = _d.sent();
|
|
329
|
+
return [2 /*return*/, response === null || response === void 0 ? void 0 : response.data];
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
};
|
|
334
|
+
return Analytics;
|
|
335
|
+
}());
|
|
336
|
+
exports.Analytics = Analytics;
|
|
331
337
|
//# sourceMappingURL=analytics.js.map
|