eventregistry 8.10.1 → 8.10.3

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.
Files changed (70) hide show
  1. package/dist/eventRegistry.d.ts +1 -0
  2. package/dist/eventRegistry.js +10 -2
  3. package/dist/eventRegistry.js.map +1 -1
  4. package/dist/queryArticles.js +1 -1
  5. package/dist/queryArticles.js.map +1 -1
  6. package/dist/queryEvent.js +1 -1
  7. package/dist/queryEvent.js.map +1 -1
  8. package/dist/queryEvents.js +1 -1
  9. package/dist/queryEvents.js.map +1 -1
  10. package/dist/queryMentions.js +1 -1
  11. package/dist/queryMentions.js.map +1 -1
  12. package/{src → dist}/types.d.ts +199 -255
  13. package/dist/types.js +3 -0
  14. package/dist/types.js.map +1 -0
  15. package/package.json +6 -5
  16. package/CHANGELOG.md +0 -116
  17. package/dist/correlations.d.ts +0 -50
  18. package/dist/correlations.js +0 -397
  19. package/dist/correlations.js.map +0 -1
  20. package/examples/autoSuggestionsExamples.ts +0 -46
  21. package/examples/countsExamples.ts +0 -34
  22. package/examples/dailySharesExamples.ts +0 -54
  23. package/examples/eventForTextExamples.ts +0 -32
  24. package/examples/feedOfNewArticlesExamples.ts +0 -82
  25. package/examples/feedOfNewEventsExamples.ts +0 -70
  26. package/examples/queryArticleExamples.ts +0 -42
  27. package/examples/queryArticlesExamples.ts +0 -248
  28. package/examples/queryEventExamples.ts +0 -99
  29. package/examples/queryEventsExamples.ts +0 -232
  30. package/examples/queryMentionsExamples.ts +0 -20
  31. package/examples/topicPageExamples.ts +0 -99
  32. package/examples/trendsExamples.ts +0 -34
  33. package/src/analytics.ts +0 -181
  34. package/src/base.ts +0 -198
  35. package/src/counts.ts +0 -119
  36. package/src/dailyShares.ts +0 -48
  37. package/src/eventForText.ts +0 -61
  38. package/src/eventRegistry.ts +0 -733
  39. package/src/index.ts +0 -125
  40. package/src/info.ts +0 -121
  41. package/src/query.ts +0 -257
  42. package/src/queryArticle.ts +0 -139
  43. package/src/queryArticles.ts +0 -608
  44. package/src/queryEvent.ts +0 -473
  45. package/src/queryEvents.ts +0 -689
  46. package/src/queryMentions.ts +0 -516
  47. package/src/queryStory.ts +0 -152
  48. package/src/recent.ts +0 -63
  49. package/src/returnInfo.ts +0 -363
  50. package/src/topicPage.ts +0 -479
  51. package/src/trends.ts +0 -63
  52. package/test/index.d.ts +0 -18
  53. package/test/jasmine.json +0 -10
  54. package/test/spec/analytics.spec.ts +0 -150
  55. package/test/spec/autoSuggestions.spec.ts +0 -54
  56. package/test/spec/info.spec.ts +0 -84
  57. package/test/spec/invalidQueries.spec.ts +0 -147
  58. package/test/spec/queryArticle.spec.ts +0 -62
  59. package/test/spec/queryArticles.spec.ts +0 -541
  60. package/test/spec/queryArticlesComplex.spec.ts +0 -298
  61. package/test/spec/queryEvent.spec.ts +0 -194
  62. package/test/spec/queryEvents.spec.ts +0 -491
  63. package/test/spec/queryEventsComplex.spec.ts +0 -188
  64. package/test/spec/queryPaging.spec.ts +0 -318
  65. package/test/spec/returnInfo.spec.ts +0 -34
  66. package/test/spec/topicPage.spec.ts +0 -83
  67. package/test/spec/utils.ts +0 -436
  68. package/test/tsconfig.json +0 -31
  69. package/tsconfig.json +0 -32
  70. package/tslint.json +0 -25
@@ -1,608 +0,0 @@
1
- import * as _ from "lodash";
2
- import { mainLangs, Query, QueryParamsBase } from "./base";
3
- import { EventRegistry } from "./eventRegistry";
4
- import { ComplexArticleQuery } from "./query";
5
- import { ArticleInfoFlags, ReturnInfo } from "./returnInfo";
6
- import { EventRegistryStatic } from "./types";
7
-
8
- export class QueryArticles extends Query<RequestArticles> {
9
- constructor(args: EventRegistryStatic.QueryArticles.Arguments = {}) {
10
- super();
11
- const {
12
- keywords,
13
- conceptUri,
14
- categoryUri,
15
- sourceUri,
16
- sourceLocationUri,
17
- sourceGroupUri,
18
- authorUri,
19
- locationUri,
20
- lang,
21
- dateStart,
22
- dateEnd,
23
- dateMentionStart,
24
- dateMentionEnd,
25
- ignoreKeywords,
26
- ignoreConceptUri,
27
- ignoreCategoryUri,
28
- ignoreSourceUri,
29
- ignoreSourceLocationUri,
30
- ignoreSourceGroupUri,
31
- ignoreAuthorUri,
32
- ignoreLocationUri,
33
- ignoreLang,
34
- keywordsLoc = "body",
35
- ignoreKeywordsLoc = "body",
36
- isDuplicateFilter = "keepAll",
37
- hasDuplicateFilter = "keepAll",
38
- eventFilter = "keepAll",
39
- startSourceRankPercentile = 0,
40
- endSourceRankPercentile = 100,
41
- minSentiment = -1,
42
- maxSentiment = 1,
43
- dataType = "news",
44
- requestedResult = new RequestArticlesInfo(),
45
- ...unsupported
46
- } = args;
47
- if (!_.isEmpty(unsupported)) {
48
- // Check ["sortBy", "sortByAsc", "returnInfo", "maxItems"] for cases when we are coming from QueryArticlesIter
49
- if (!_.some(_.keys(unsupported), (key) => _.includes(["sortBy", "sortByAsc", "returnInfo", "maxItems"], key))) {
50
- console.warn(`QueryArticles: Unsupported parameters detected: ${JSON.stringify(unsupported)}. Please check the documentation.`);
51
- }
52
- }
53
- this.setVal("action", "getArticles");
54
- this.setQueryArrVal(keywords, "keyword", "keywordOper", "and");
55
- this.setQueryArrVal(conceptUri, "conceptUri", "conceptOper", "and");
56
- this.setQueryArrVal(categoryUri, "categoryUri", "categoryOper", "or");
57
- this.setQueryArrVal(sourceUri, "sourceUri", "sourceOper", "or");
58
- this.setQueryArrVal(sourceLocationUri, "sourceLocationUri", undefined, "or");
59
- this.setQueryArrVal(sourceGroupUri, "sourceGroupUri", "sourceGroupOper", "or");
60
- this.setQueryArrVal(authorUri, "authorUri", "authorOper", "or");
61
- this.setQueryArrVal(locationUri, "locationUri", undefined, "or");
62
- this.setQueryArrVal(lang, "lang", undefined, "or");
63
- if (!_.isUndefined(dateStart)) {
64
- this.setDateVal("dateStart", dateStart);
65
- }
66
- if (!_.isUndefined(dateEnd)) {
67
- this.setDateVal("dateEnd", dateEnd);
68
- }
69
- if (!_.isUndefined(dateMentionStart)) {
70
- this.setDateVal("dateMentionStart", dateMentionStart);
71
- }
72
- if (!_.isUndefined(dateMentionEnd)) {
73
- this.setDateVal("dateMentionEnd", dateMentionEnd);
74
- }
75
- this.setQueryArrVal(ignoreKeywords, "ignoreKeyword", undefined, "or");
76
- this.setQueryArrVal(ignoreConceptUri, "ignoreConceptUri", undefined, "or");
77
- this.setQueryArrVal(ignoreCategoryUri, "ignoreCategoryUri", undefined, "or");
78
- this.setQueryArrVal(ignoreSourceUri, "ignoreSourceUri", undefined, "or");
79
- this.setQueryArrVal(ignoreSourceLocationUri, "ignoreSourceLocationUri", undefined, "or");
80
- this.setQueryArrVal(ignoreSourceGroupUri, "ignoreSourceGroupUri", undefined, "or");
81
- this.setQueryArrVal(ignoreAuthorUri, "ignoreAuthorUri", undefined, "or");
82
- this.setQueryArrVal(ignoreLocationUri, "ignoreLocationUri", undefined, "or");
83
- this.setQueryArrVal(ignoreLang, "ignoreLang", undefined, "or");
84
- this.setValIfNotDefault("keywordLoc", keywordsLoc, "body");
85
- this.setValIfNotDefault("ignoreKeywordLoc", ignoreKeywordsLoc, "body");
86
- this.setValIfNotDefault("isDuplicateFilter", isDuplicateFilter, "keepAll");
87
- this.setValIfNotDefault("hasDuplicateFilter", hasDuplicateFilter, "keepAll");
88
- this.setValIfNotDefault("eventFilter", eventFilter, "keepAll");
89
- if (startSourceRankPercentile < 0 || startSourceRankPercentile % 10 !== 0 || startSourceRankPercentile > 100) {
90
- throw new Error("StartSourceRankPercentile: Value should be in range 0-90 and divisible by 10.");
91
- }
92
- if (endSourceRankPercentile < 0 || endSourceRankPercentile % 10 !== 0 || endSourceRankPercentile > 100) {
93
- throw new Error("EndSourceRankPercentile: Value should be in range 0-90 and divisible by 10.");
94
- }
95
- if (startSourceRankPercentile > endSourceRankPercentile) {
96
- throw new Error("SourceRankPercentile: startSourceRankPercentile should be less than endSourceRankPercentile");
97
- }
98
-
99
- if (startSourceRankPercentile !== 0 ) {
100
- this.setVal("startSourceRankPercentile", startSourceRankPercentile);
101
- }
102
-
103
- if (endSourceRankPercentile !== 100 ) {
104
- this.setVal("endSourceRankPercentile", endSourceRankPercentile);
105
- }
106
- if (minSentiment > -1 && minSentiment <= 1 ) {
107
- this.setVal("minSentiment", minSentiment);
108
- }
109
- if (maxSentiment >= -1 && maxSentiment < 1 ) {
110
- this.setVal("maxSentiment", maxSentiment);
111
- }
112
-
113
- this.setValIfNotDefault("dataType", dataType, "news");
114
- this.setRequestedResult(requestedResult);
115
- }
116
-
117
- public get path() {
118
- return "/api/v1/article";
119
- }
120
-
121
- public setRequestedResult(requestArticles) {
122
- if (!(requestArticles instanceof RequestArticles)) {
123
- throw new Error("QueryArticles class can only accept result requests that are of type RequestArticles");
124
- }
125
- this.resultTypeList = [requestArticles];
126
- }
127
-
128
- public static initWithArticleUriList(...args);
129
- public static initWithArticleUriList(uriList) {
130
- const q = new QueryArticles();
131
- if (!_.isArray(uriList)) {
132
- throw new Error("uriList has to be a list of strings that represent article uris");
133
- }
134
- q.params = {
135
- action: "getArticles",
136
- articleUri: uriList,
137
- };
138
- return q;
139
- }
140
-
141
- public static initWithArticleUriWgtList(...args);
142
- public static initWithArticleUriWgtList(uriWgtList) {
143
- const q = new QueryArticles();
144
- if (!_.isArray(uriWgtList)) {
145
- throw new Error("uriList has to be a list of strings that represent article uris");
146
- }
147
- q.params = {
148
- action: "getArticles",
149
- articleUriWgtList: _.join(uriWgtList, ","),
150
- };
151
- return q;
152
- }
153
-
154
- public static initWithComplexQuery(...args);
155
- public static initWithComplexQuery(complexQuery) {
156
- const query = new QueryArticles();
157
- if (complexQuery instanceof ComplexArticleQuery) {
158
- query.setVal("query", JSON.stringify(complexQuery.getQuery()));
159
- } else if (_.isString(complexQuery)) {
160
- try {
161
- JSON.parse(complexQuery);
162
- } catch {
163
- console.error("Failed to parse the provided string content as a JSON object. Please check the content provided as a parameter to the initWithComplexQuery() method");
164
- }
165
- query.setVal("query", complexQuery);
166
- } else if (_.isObject(complexQuery)) {
167
- query.setVal("query", JSON.stringify(complexQuery));
168
- } else {
169
- throw new Error("The instance of query parameter was not a ComplexArticleQuery, a string or an object");
170
- }
171
- return query;
172
- }
173
-
174
- }
175
-
176
- export class QueryArticlesIter extends QueryArticles {
177
- private readonly er: EventRegistry;
178
- private readonly sortBy;
179
- private readonly sortByAsc;
180
- private readonly returnInfo;
181
- private readonly maxItems;
182
- private page = 0;
183
- private pages = 1;
184
- private items = [];
185
- private returnedSoFar = 0;
186
- private index = 0;
187
- private callback: (item) => void = _.noop;
188
- private doneCallback: (error?) => void = _.noop;
189
- private errorMessage;
190
-
191
- constructor(er: EventRegistry, args: {[name: string]: any} = {}) {
192
- super(args);
193
- _.defaults(args, {
194
- sortBy: "rel",
195
- sortByAsc: false,
196
- returnInfo: undefined,
197
- maxItems: -1,
198
- });
199
- const {sortBy, sortByAsc, returnInfo, maxItems} = args;
200
- this.er = er;
201
- this.sortBy = sortBy;
202
- this.sortByAsc = sortByAsc;
203
- this.returnInfo = returnInfo;
204
- this.maxItems = maxItems;
205
- }
206
-
207
- public async count() {
208
- this.setRequestedResult(new RequestArticlesInfo());
209
- const response = await this.er.execQuery(this);
210
-
211
- if (_.has(response, "error")) {
212
- console.error(_.get(response, "error"));
213
- }
214
-
215
- return _.get(response, "articles.totalResults", 0);
216
- }
217
-
218
- public execQuery(callback: (item) => void, doneCallback?: (error?) => void) {
219
- if (callback) { this.callback = callback; }
220
- if (doneCallback) { this.doneCallback = doneCallback; }
221
- this.iterate();
222
- }
223
-
224
- public static initWithComplexQuery(er: EventRegistry, complexQuery, params: {[name: string]: any} = {}) {
225
- const query = new QueryArticlesIter(er, params);
226
- if (complexQuery instanceof ComplexArticleQuery) {
227
- query.setVal("query", JSON.stringify(complexQuery.getQuery()));
228
- } else if (_.isString(complexQuery)) {
229
- query.setVal("query", complexQuery);
230
- } else if (_.isObject(complexQuery)) {
231
- query.setVal("query", JSON.stringify(complexQuery));
232
- } else {
233
- throw new Error("The instance of query parameter was not a ComplexArticleQuery, a string or an object");
234
- }
235
- return query;
236
- }
237
-
238
- private async iterate() {
239
- if (this.current) {
240
- this.callback(this.current);
241
- this.index += 1;
242
- } else if (!await this.getNextBatch()) {
243
- this.doneCallback(this.errorMessage);
244
- return;
245
- }
246
- return this.iterate();
247
- }
248
-
249
- /**
250
- * Extract the results according to maxItems
251
- * @param response response from the backend
252
- */
253
- private extractResults(response): Array<{[name: string]: any}> {
254
- const results = _.get(response, "articles.results", []);
255
- const extractedSize = this.maxItems !== -1 ? this.maxItems - this.returnedSoFar : _.size(results);
256
- return _.compact(_.pullAt(results, _.range(0, extractedSize)) as Array<{}>);
257
- }
258
-
259
- private get current() {
260
- return this.items[this.index] || undefined;
261
- }
262
-
263
- private async getNextBatch() {
264
- try {
265
- this.page += 1;
266
- if (this.page > this.pages || (this.maxItems !== -1 && this.returnedSoFar >= this.maxItems)) {
267
- return false;
268
- }
269
- const requestArticles = new RequestArticlesInfo({
270
- page: this.page,
271
- sortBy: this.sortBy,
272
- sortByAsc: this.sortByAsc,
273
- returnInfo: this.returnInfo,
274
- });
275
- this.setRequestedResult(requestArticles);
276
- if (this.er.verboseOutput) {
277
- console.log(`Downloading article page ${this.page}...`);
278
- }
279
- const response = await this.er.execQuery(this);
280
- const error = _.get(response, "error", "");
281
- if (error) {
282
- this.errorMessage = `Error while obtaining a list of articles: ${this.errorMessage}`;
283
- } else {
284
- this.pages = _.get(response, "articles.pages", 0);
285
- }
286
- const results = this.extractResults(response);
287
- this.returnedSoFar += _.size(results);
288
- this.items = [...this.items, ...results];
289
- return true;
290
- } catch (error) {
291
- console.error(error);
292
- return false;
293
- }
294
- }
295
-
296
- }
297
-
298
- export class RequestArticles {}
299
-
300
- export class RequestArticlesInfo extends RequestArticles {
301
- public resultType = "articles";
302
- public params;
303
- constructor({page = 1,
304
- count = 200,
305
- sortBy = "date",
306
- sortByAsc = false,
307
- returnInfo = undefined,
308
- ...unsupported
309
- } = {}) {
310
- super();
311
- if (!_.isEmpty(unsupported)) {
312
- console.warn(`RequestArticlesInfo: Unsupported parameters detected: ${JSON.stringify(unsupported)}. Please check the documentation.`);
313
- }
314
- if (page < 1) {
315
- throw new RangeError("page has to be >= 1");
316
- }
317
- if (count > 200) {
318
- throw new RangeError("at most 200 articles can be returned per call");
319
- }
320
- this.params = {};
321
- this.params["articlesPage"] = page;
322
- this.params["articlesCount"] = count;
323
- this.params["articlesSortBy"] = sortBy;
324
- this.params["articlesSortByAsc"] = sortByAsc;
325
- if (!!returnInfo) {
326
- this.params = _.extend({}, this.params, returnInfo.getParams("articles"));
327
- }
328
- }
329
- }
330
-
331
- export class RequestArticlesUriWgtList extends RequestArticles {
332
- public resultType = "uriWgtList";
333
- public params;
334
- constructor({page = 1,
335
- count = 10000,
336
- sortBy = "fq",
337
- sortByAsc = false,
338
- ...unsupported
339
- } = {}) {
340
- super();
341
- if (!_.isEmpty(unsupported)) {
342
- console.warn(`RequestArticlesUriWgtList: Unsupported parameters detected: ${JSON.stringify(unsupported)}. Please check the documentation.`);
343
- }
344
- if (page < 1) {
345
- throw new RangeError("page has to be >= 1");
346
- }
347
- if (count > 50000) {
348
- throw new RangeError("at most 50000 items can be returned per call");
349
- }
350
- this.params = {};
351
- this.params["uriWgtListPage"] = page;
352
- this.params["uriWgtListCount"] = count;
353
- this.params["uriWgtListSortBy"] = sortBy;
354
- this.params["uriWgtListSortByAsc"] = sortByAsc;
355
- }
356
-
357
- public setPage(page) {
358
- if (page < 1) {
359
- throw new RangeError("page has to be >= 1");
360
- }
361
- this.params["uriWgtListPage"] = page;
362
- }
363
- }
364
-
365
- export class RequestArticlesTimeAggr extends RequestArticles {
366
- public resultType = "timeAggr";
367
- }
368
-
369
- export class RequestArticlesConceptAggr extends RequestArticles {
370
- public resultType = "conceptAggr";
371
- public params;
372
- constructor({
373
- conceptCount = 25,
374
- conceptCountPerType = undefined,
375
- conceptScoring = "importance",
376
- articlesSampleSize = 10000,
377
- returnInfo = new ReturnInfo(),
378
- ...unsupported
379
- } = {}) {
380
- super();
381
- if (!_.isEmpty(unsupported)) {
382
- console.warn(`RequestArticlesConceptAggr: Unsupported parameters detected: ${JSON.stringify(unsupported)}. Please check the documentation.`);
383
- }
384
- if (conceptCount > 500) {
385
- throw new RangeError("At most 500 concepts can be returned per call");
386
- }
387
- if (articlesSampleSize > 20000) {
388
- throw new RangeError("at most 20000 articles can be used for computation sample");
389
- }
390
- this.params = {};
391
- this.params["conceptAggrConceptCount"] = conceptCount;
392
- this.params["conceptAggrSampleSize"] = articlesSampleSize;
393
- this.params["conceptAggrScoring"] = conceptScoring;
394
- if (!_.isUndefined(conceptCountPerType)) {
395
- this.params["conceptAggrConceptCountPerType"] = conceptCountPerType;
396
- }
397
- this.params = _.extend({}, this.params, returnInfo.getParams("conceptAggr"));
398
- }
399
- }
400
-
401
- export class RequestArticlesCategoryAggr extends RequestArticles {
402
- public resultType = "categoryAggr";
403
- public params;
404
- constructor({articlesSampleSize = 20000,
405
- returnInfo = new ReturnInfo(),
406
- ...unsupported
407
- } = {}) {
408
- super();
409
- if (!_.isEmpty(unsupported)) {
410
- console.warn(`RequestArticlesCategoryAggr: Unsupported parameters detected: ${JSON.stringify(unsupported)}. Please check the documentation.`);
411
- }
412
- if (articlesSampleSize > 50000) {
413
- throw new RangeError("at most 50000 articles can be used for computation sample");
414
- }
415
- this.params = {};
416
- this.params["categoryAggrSampleSize"] = articlesSampleSize;
417
- this.params = _.extend({}, this.params, returnInfo.getParams("categoryAggr"));
418
- }
419
- }
420
-
421
- export class RequestArticlesSourceAggr extends RequestArticles {
422
- public resultType = "sourceAggr";
423
- public params;
424
- constructor({
425
- sourceCount = 50,
426
- normalizeBySourceArts = false,
427
- returnInfo = new ReturnInfo(),
428
- ...unsupported
429
- } = {}) {
430
- super();
431
- if (!_.isEmpty(unsupported)) {
432
- console.warn(`RequestArticlesSourceAggr: Unsupported parameters detected: ${JSON.stringify(unsupported)}. Please check the documentation.`);
433
- }
434
- this.params = {};
435
- this.params["sourceAggrSourceCount"] = sourceCount;
436
- this.params = _.extend({}, this.params, returnInfo.getParams("sourceAggr"));
437
- }
438
- }
439
-
440
- export class RequestArticlesKeywordAggr extends RequestArticles {
441
- public resultType = "keywordAggr";
442
- public params;
443
- constructor({
444
- articlesSampleSize = 2000,
445
- ...unsupported
446
- } = {}) {
447
- super();
448
- if (!_.isEmpty(unsupported)) {
449
- console.warn(`RequestArticlesKeywordAggr: Unsupported parameters detected: ${JSON.stringify(unsupported)}. Please check the documentation.`);
450
- }
451
- if (articlesSampleSize > 20000) {
452
- throw new RangeError("at most 20000 articles can be used for computation sample");
453
- }
454
- this.params = {};
455
- this.params["keywordAggrSampleSize"] = articlesSampleSize;
456
- }
457
- }
458
-
459
- export class RequestArticlesConceptGraph extends RequestArticles {
460
- public resultType = "conceptGraph";
461
- public params;
462
- constructor({conceptCount = 25,
463
- linkCount = 50,
464
- articlesSampleSize = 10000,
465
- skipQueryConcepts = true,
466
- returnInfo = new ReturnInfo(),
467
- ...unsupported
468
- } = {}) {
469
- super();
470
- if (!_.isEmpty(unsupported)) {
471
- console.warn(`RequestArticlesConceptGraph: Unsupported parameters detected: ${JSON.stringify(unsupported)}. Please check the documentation.`);
472
- }
473
- if (conceptCount > 1000) {
474
- throw new RangeError("At most 1000 concepts can be returned per call");
475
- }
476
- if (linkCount > 2000) {
477
- throw new RangeError("at most 2000 links can be returned per call");
478
- }
479
- if (articlesSampleSize > 50000) {
480
- throw new RangeError("at most 50000 results can be used for computation sample");
481
- }
482
- this.params = {};
483
- this.params["conceptGraphConceptCount"] = conceptCount;
484
- this.params["conceptGraphLinkCount"] = linkCount;
485
- this.params["conceptGraphSampleSize"] = articlesSampleSize;
486
- this.params["conceptGraphSkipQueryConcepts"] = skipQueryConcepts;
487
- this.params = _.extend({}, this.params, returnInfo.getParams("conceptGraph"));
488
- }
489
- }
490
-
491
- export class RequestArticlesConceptMatrix extends RequestArticles {
492
- public resultType = "conceptMatrix";
493
- public params;
494
- constructor({conceptCount = 25,
495
- measure = "pmi",
496
- articlesSampleSize = 10000,
497
- returnInfo = new ReturnInfo(),
498
- ...unsupported
499
- } = {}) {
500
- super();
501
- if (!_.isEmpty(unsupported)) {
502
- console.warn(`RequestArticlesConceptMatrix: Unsupported parameters detected: ${JSON.stringify(unsupported)}. Please check the documentation.`);
503
- }
504
- if (conceptCount > 200) {
505
- throw new RangeError("At most 200 concepts can be returned per call");
506
- }
507
- if (articlesSampleSize > 50000) {
508
- throw new RangeError("at most 50000 results can be used for computation sample");
509
- }
510
- this.params = {};
511
- this.params["conceptMatrixConceptCount"] = conceptCount;
512
- this.params["conceptMatrixMeasure"] = measure;
513
- this.params["conceptMatrixSampleSize"] = articlesSampleSize;
514
- this.params = _.extend({}, this.params, returnInfo.getParams("conceptMatrix"));
515
- }
516
- }
517
-
518
- export class RequestArticlesConceptTrends extends RequestArticles {
519
- public resultType = "conceptTrends";
520
- public params;
521
- constructor({
522
- conceptUris = undefined,
523
- conceptCount = 25,
524
- articlesSampleSize = 10000,
525
- returnInfo = new ReturnInfo(),
526
- ...unsupported
527
- } = {}) {
528
- super();
529
- if (!_.isEmpty(unsupported)) {
530
- console.warn(`RequestArticlesConceptTrends: Unsupported parameters detected: ${JSON.stringify(unsupported)}. Please check the documentation.`);
531
- }
532
- if (conceptCount > 50) {
533
- throw new RangeError("At most 50 concepts can be returned per call");
534
- }
535
- if (articlesSampleSize > 50000) {
536
- throw new RangeError("at most 50000 results can be used for computation sample");
537
- }
538
- this.params = {};
539
- if (!_.isUndefined(conceptUris)) {
540
- this.params["conceptTrendsConceptUri"] = conceptUris;
541
- }
542
- this.params["conceptTrendsConceptCount"] = conceptCount;
543
- this.params["conceptTrendsSampleSize"] = articlesSampleSize;
544
- this.params = _.extend({}, this.params, returnInfo.getParams("conceptTrends"));
545
- }
546
- }
547
-
548
- export class RequestArticlesDateMentionAggr extends RequestArticles {
549
- public resultType = "dateMentionAggr";
550
- }
551
-
552
- export class RequestArticlesRecentActivity extends RequestArticles {
553
- public resultType = "recentActivityArticles";
554
- public params;
555
- constructor({maxArticleCount = 100,
556
- updatesAfterNewsUri = undefined,
557
- updatesafterBlogUri = undefined,
558
- updatesAfterPrUri = undefined,
559
- updatesAfterTm = undefined,
560
- updatesAfterMinsAgo = undefined,
561
- updatesUntilTm = undefined,
562
- updatesUntilMinsAgo = undefined,
563
- mandatorySourceLocation = false,
564
- returnInfo = undefined,
565
- ...unsupported
566
- } = {}) {
567
- super();
568
- if (!_.isEmpty(unsupported)) {
569
- console.warn(`RequestArticlesRecentActivity: Unsupported parameters detected: ${JSON.stringify(unsupported)}. Please check the documentation.`);
570
- }
571
- if (maxArticleCount > 2000) {
572
- throw new RangeError("At most 2000 articles can be returned per call");
573
- }
574
- if (!_.isUndefined(updatesAfterTm) && !_.isUndefined(updatesAfterMinsAgo)) {
575
- throw new Error("You should specify either updatesAfterTm or updatesAfterMinsAgo parameter, but not both");
576
- }
577
- if (!_.isUndefined(updatesUntilTm) && !_.isUndefined(updatesUntilMinsAgo)) {
578
- throw new Error("You should specify either updatesUntilTm or updatesUntilMinsAgo parameter, but not both");
579
- }
580
- this.params = {};
581
- this.params["recentActivityArticlesMaxArticleCount"] = maxArticleCount;
582
- if (!_.isUndefined(updatesAfterTm)) {
583
- this.params["recentActivityArticlesUpdatesAfterTm"] = QueryParamsBase.encodeDateTime(updatesAfterTm);
584
- }
585
- if (!_.isUndefined(updatesAfterMinsAgo)) {
586
- this.params["recentActivityArticlesUpdatesAfterMinsAgo"] = updatesAfterMinsAgo;
587
- }
588
- if (!_.isUndefined(updatesUntilTm)) {
589
- this.params["recentActivityArticlesUpdatesUntilTm"] = QueryParamsBase.encodeDateTime(updatesUntilTm);
590
- }
591
- if (!_.isUndefined(updatesUntilMinsAgo)) {
592
- this.params["recentActivityArticlesUpdatesUntilMinsAgo"] = updatesUntilMinsAgo;
593
- }
594
- if (!_.isUndefined(updatesAfterNewsUri)) {
595
- this.params["recentActivityArticlesNewsUpdatesAfterUri"] = updatesAfterNewsUri;
596
- }
597
- if (!_.isUndefined(updatesafterBlogUri)) {
598
- this.params["recentActivityArticlesNewsUpdatesAfterUri"] = updatesafterBlogUri;
599
- }
600
- if (!_.isUndefined(updatesAfterPrUri)) {
601
- this.params["recentActivityArticlesNewsUpdatesAfterUri"] = updatesAfterPrUri;
602
- }
603
- this.params["recentActivityArticlesMandatorySourceLocation"] = mandatorySourceLocation;
604
- if (!!returnInfo) {
605
- this.params = _.extend({}, this.params, returnInfo.getParams("recentActivityArticles"));
606
- }
607
- }
608
- }