eventregistry 8.9.2 → 8.10.2

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