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,684 +0,0 @@
1
- import * as _ from "lodash";
2
- import { Query, QueryParamsBase } from "./base";
3
- import { EventRegistry } from "./eventRegistry";
4
- import { ComplexEventQuery } from "./query";
5
- import { ReturnInfo } from "./returnInfo";
6
- import { EventRegistryStatic } from "./types";
7
-
8
- /**
9
- * @class QueryEvents
10
- * Class for obtaining available info for one or more events in the Event Registry
11
- */
12
- export class QueryEvents extends Query<RequestEvents> {
13
- public params = {};
14
- constructor(args: EventRegistryStatic.QueryEvents.Arguments = {}) {
15
- super();
16
- const {
17
- keywords,
18
- conceptUri,
19
- categoryUri,
20
- sourceUri,
21
- sourceLocationUri,
22
- sourceGroupUri,
23
- authorUri,
24
- locationUri,
25
- lang,
26
- dateStart,
27
- dateEnd,
28
- reportingDateStart,
29
- reportingDateEnd,
30
- minSentiment = -1,
31
- maxSentiment = 1,
32
- minArticlesInEvent,
33
- maxArticlesInEvent,
34
- dateMentionStart,
35
- dateMentionEnd,
36
- ignoreKeywords,
37
- ignoreConceptUri,
38
- ignoreCategoryUri,
39
- ignoreSourceUri,
40
- ignoreSourceLocationUri,
41
- ignoreSourceGroupUri,
42
- ignoreAuthorUri,
43
- ignoreLocationUri,
44
- ignoreLang,
45
- keywordsLoc = "body",
46
- ignoreKeywordsLoc = "body",
47
- categoryIncludeSub = true,
48
- ignoreCategoryIncludeSub = true,
49
- requestedResult = new RequestEventsInfo(),
50
- } = args;
51
-
52
- this.setVal("action", "getEvents");
53
- this.setQueryArrVal(keywords, "keyword", "keywordOper", "and");
54
- this.setQueryArrVal(conceptUri, "conceptUri", "conceptOper", "and");
55
- this.setQueryArrVal(categoryUri, "categoryUri", "categoryOper", "or");
56
- this.setQueryArrVal(sourceUri, "sourceUri", undefined, "or");
57
- this.setQueryArrVal(sourceLocationUri, "sourceLocationUri", undefined, "or");
58
- this.setQueryArrVal(sourceGroupUri, "sourceGroupUri", undefined, "or");
59
- this.setQueryArrVal(authorUri, "authorUri", "authorOper", "or");
60
- this.setQueryArrVal(locationUri, "locationUri", undefined, "or");
61
- this.setQueryArrVal(lang, "lang", undefined, "or");
62
- if (!_.isUndefined(dateStart)) {
63
- this.setDateVal("dateStart", dateStart);
64
- }
65
- if (!_.isUndefined(dateEnd)) {
66
- this.setDateVal("dateEnd", dateEnd);
67
- }
68
- if (!_.isUndefined(reportingDateStart)) {
69
- this.setDateVal("reportingDateStart", reportingDateStart);
70
- }
71
- if (!_.isUndefined(reportingDateEnd)) {
72
- this.setDateVal("reportingDateEnd", reportingDateEnd);
73
- }
74
-
75
- if (minSentiment > -1 && minSentiment <= 1 ) {
76
- this.setVal("minSentiment", minSentiment);
77
- }
78
-
79
- if (maxSentiment >= -1 && maxSentiment < 1 ) {
80
- this.setVal("maxSentiment", maxSentiment);
81
- }
82
-
83
- this.setValIfNotDefault("minArticlesInEvent", minArticlesInEvent, undefined);
84
- this.setValIfNotDefault("maxArticlesInEvent", maxArticlesInEvent, undefined);
85
-
86
- if (!_.isUndefined(dateMentionStart)) {
87
- this.setDateVal("dateMentionStart", dateMentionStart);
88
- }
89
-
90
- if (!_.isUndefined(dateMentionEnd)) {
91
- this.setDateVal("dateMentionEnd", dateMentionEnd);
92
- }
93
-
94
- // for the negative conditions, only the OR is a valid operator type
95
- this.setQueryArrVal(ignoreKeywords, "ignoreKeywords", undefined, "or");
96
- this.setQueryArrVal(ignoreConceptUri, "ignoreConceptUri", undefined, "or");
97
- this.setQueryArrVal(ignoreCategoryUri, "ignoreCategoryUri", undefined, "or");
98
- this.setQueryArrVal(ignoreSourceUri, "ignoreSourceUri", undefined, "or");
99
- this.setQueryArrVal(ignoreSourceLocationUri, "ignoreSourceLocationUri", undefined, "or");
100
- this.setQueryArrVal(ignoreSourceGroupUri, "ignoreSourceGroupUri", undefined, "or");
101
- this.setQueryArrVal(ignoreAuthorUri, "ignoreAuthorUri", undefined, "or");
102
- this.setQueryArrVal(ignoreLocationUri, "ignoreLocationUri", undefined, "or");
103
-
104
- this.setQueryArrVal(ignoreLang, "ignoreLang", undefined, "or");
105
-
106
- this.setValIfNotDefault("keywordLoc", keywordsLoc, "body");
107
- this.setValIfNotDefault("ignoreKeywordLoc", ignoreKeywordsLoc, "body");
108
-
109
- this.setValIfNotDefault("categoryIncludeSub", categoryIncludeSub, true);
110
- this.setValIfNotDefault("ignoreCategoryIncludeSub", ignoreCategoryIncludeSub, true);
111
- this.setRequestedResult(requestedResult);
112
- }
113
-
114
- public get path() {
115
- return "/api/v1/event";
116
- }
117
-
118
- /**
119
- * Set the single result type that you would like to be returned. Any previously set result types will be overwritten.
120
- * Result types can be the classes that extend RequestEvent base class (see classes below).
121
- */
122
- public setRequestedResult(requestEvents: RequestEvents) {
123
- if (!(requestEvents instanceof RequestEvents)) {
124
- throw new Error("QueryEvents class can only accept result requests that are of type RequestEvents");
125
- }
126
- this.resultTypeList = [
127
- requestEvents,
128
- ];
129
- }
130
- /**
131
- * Set a custom list of event uris. The results will be then computed on this list - no query will be done (all conditions will be ignored).
132
- */
133
- public static initWithEventUriList(uriList: string[]) {
134
- const query = new QueryEvents();
135
- if (!_.isArray(uriList)) {
136
- throw new Error("uriList has to be a list of strings that represent event uris");
137
- }
138
- query.params = {
139
- action: "getEvents",
140
- eventUriList: _.join(uriList, ","),
141
- };
142
- return query;
143
- }
144
-
145
- /**
146
- * Set a custom list of event uris. The results will be then computed on this list - no query will be done (all conditions will be ignored).
147
- */
148
- public static initWithEventUriWgtList(...args);
149
- public static initWithEventUriWgtList(uriWgtList: string[]) {
150
- const query = new QueryEvents();
151
- if (!_.isArray(uriWgtList)) {
152
- throw new Error("uriWgtList has to be a list of strings that represent event uris");
153
- }
154
- query.params = {
155
- action: "getEvents",
156
- eventUriWgtList: _.join(uriWgtList, ","),
157
- };
158
- return query;
159
- }
160
-
161
- public static initWithComplexQuery(...args);
162
- public static initWithComplexQuery(complexQuery) {
163
- const query = new QueryEvents();
164
- if (complexQuery instanceof ComplexEventQuery) {
165
- query.setVal("query", JSON.stringify(complexQuery.getQuery()));
166
- } else if (_.isString(complexQuery)) {
167
- query.setVal("query", complexQuery);
168
- } else if (_.isObject(complexQuery)) {
169
- query.setVal("query", JSON.stringify(complexQuery));
170
- } else {
171
- throw new Error("The instance of query parameter was not a ComplexEventQuery, a string or an object");
172
- }
173
- return query;
174
- }
175
- }
176
-
177
- /**
178
- * @class QueryEventsIter
179
- * Class for iterating through all the events via callbacks
180
- */
181
- export class QueryEventsIter extends QueryEvents {
182
- private readonly er: EventRegistry;
183
- private readonly sortBy;
184
- private readonly sortByAsc;
185
- private readonly returnInfo;
186
- private readonly maxItems;
187
- private page = 0;
188
- private pages = 1;
189
- private items = [];
190
- private returnedSoFar = 0;
191
- private index = 0;
192
- private callback: (item) => void = _.noop;
193
- private doneCallback: (error?) => void = _.noop;
194
- private errorMessage;
195
-
196
- constructor(er: EventRegistry, args: EventRegistryStatic.QueryEvents.IteratorArguments = {}) {
197
- super(args as EventRegistryStatic.QueryEvents.Arguments);
198
- const {
199
- sortBy = "rel",
200
- sortByAsc = false,
201
- returnInfo = undefined,
202
- maxItems = -1,
203
- } = args;
204
- this.er = er;
205
- this.sortBy = sortBy;
206
- this.sortByAsc = sortByAsc;
207
- this.returnInfo = returnInfo;
208
- this.maxItems = maxItems;
209
- }
210
-
211
- public async count(): Promise<number> {
212
- this.setRequestedResult(new RequestEventsInfo());
213
- const response = await this.er.execQuery(this);
214
- if (_.has(response, "error")) {
215
- console.error(_.get(response, "error"));
216
- }
217
- return _.get(response, "events.totalResults", 0);
218
- }
219
-
220
- /**
221
- * Execute query and fetch batches of articles of the specified size (eventBatchSize)
222
- * @param callback callback function that'll be called every time we get a new batch of events from the backend
223
- * @param doneCallback callback function that'll be called when everything is complete
224
- */
225
- public execQuery(callback: (item) => void, doneCallback?: (error?) => void) {
226
- if (callback) { this.callback = callback; }
227
- if (doneCallback) { this.doneCallback = doneCallback; }
228
- this.iterate();
229
- }
230
-
231
- public static initWithComplexQuery(er, complexQuery, args: EventRegistryStatic.QueryEvents.IteratorArguments = {}) {
232
- const query = new QueryEventsIter(er, args);
233
- if (complexQuery instanceof ComplexEventQuery) {
234
- query.setVal("query", JSON.stringify(complexQuery.getQuery()));
235
- } else if (_.isString(complexQuery)) {
236
- query.setVal("query", complexQuery);
237
- } else if (_.isObject(complexQuery)) {
238
- query.setVal("query", JSON.stringify(complexQuery));
239
- } else {
240
- throw new Error("The instance of query parameter was not a ComplexEventQuery, a string or an object");
241
- }
242
- return query;
243
- }
244
-
245
- private async iterate() {
246
- if (this.current) {
247
- this.callback(this.current);
248
- this.index += 1;
249
- } else if (!await this.getNextBatch()) {
250
- this.doneCallback(this.errorMessage);
251
- return;
252
- }
253
- return this.iterate();
254
- }
255
-
256
- /**
257
- * Extract the results according to maxItems
258
- * @param response response from the backend
259
- */
260
- private extractResults(response): Array<{[name: string]: any}> {
261
- const results = _.get(response, "events.results", []);
262
- const extractedSize = this.maxItems !== -1 ? this.maxItems - this.returnedSoFar : _.size(results);
263
- return _.compact(_.pullAt(results, _.range(0, extractedSize)) as Array<{}>);
264
- }
265
-
266
- private get current() {
267
- return this.items[this.index] || undefined;
268
- }
269
-
270
- private async getNextBatch() {
271
- try {
272
- this.page += 1;
273
- if (this.page > this.pages || (this.maxItems !== -1 && this.returnedSoFar >= this.maxItems)) {
274
- return false;
275
- }
276
- const requestEventsInfo = new RequestEventsInfo({
277
- page: this.page,
278
- count: 50,
279
- sortBy: this.sortBy,
280
- sortByAsc: this.sortByAsc,
281
- returnInfo: this.returnInfo,
282
- });
283
- this.setRequestedResult(requestEventsInfo);
284
- if (this.er.verboseOutput) {
285
- console.log(`Downloading event page ${this.page}...`);
286
- }
287
- const response = await this.er.execQuery(this);
288
- const error = _.get(response, "error", "");
289
- if (error) {
290
- this.errorMessage = `Error while obtaining a list of events: ${_.get(response, "error")}`;
291
- } else {
292
- this.pages = _.get(response, "events.pages", 0);
293
- }
294
- const results = this.extractResults(response);
295
- this.returnedSoFar += _.size(results);
296
- this.items = [...this.items, ...results];
297
- return true;
298
- } catch (error) {
299
- console.error(error);
300
- return false;
301
- }
302
- }
303
- }
304
-
305
- export class RequestEvents {}
306
-
307
- /**
308
- * @class RequestEventsInfo
309
- * Return event details for resulting events.
310
- */
311
- export class RequestEventsInfo extends RequestEvents {
312
- public resultType = "events";
313
- public params;
314
- constructor(args: EventRegistryStatic.QueryEvents.RequestEventsInfoArguments = {}) {
315
- super();
316
- const {
317
- page = 1,
318
- count = 50,
319
- sortBy = "rel",
320
- sortByAsc = false,
321
- returnInfo = undefined,
322
- } = args;
323
- if (page < 1) {
324
- throw new RangeError("Page has to be >= 1");
325
- }
326
- if (count > 50) {
327
- throw new RangeError("At most 50 events can be returned per call");
328
- }
329
- this.params = {};
330
- this.params["eventsPage"] = page;
331
- this.params["eventsCount"] = count;
332
- this.params["eventsSortBy"] = sortBy;
333
- this.params["eventsSortByAsc"] = sortByAsc;
334
- if (!!returnInfo) {
335
- this.params = _.extend({}, this.params, returnInfo.getParams("events"));
336
- }
337
- }
338
- }
339
-
340
- /**
341
- * @class RequestEventsUriList
342
- * Return a simple list of event uris together with the scores for resulting events.
343
- */
344
- export class RequestEventsUriWgtList extends RequestEvents {
345
- public resultType = "uriWgtList";
346
- public params;
347
-
348
- constructor(args: EventRegistryStatic.QueryEvents.RequestEventsUriWgtListArguments = {}) {
349
- super();
350
- const {
351
- page = 1,
352
- count = 50000,
353
- sortBy = "rel",
354
- sortByAsc = false,
355
- ...unsupported
356
- } = args;
357
- if (!_.isEmpty(unsupported)) {
358
- console.warn(`RequestEventsUriWgtList: Unsupported parameters detected: ${JSON.stringify(unsupported)}. Please check the documentation.`);
359
- }
360
- if (page < 1) {
361
- throw new RangeError("Page has to be >= 1");
362
- }
363
- if (count > 100000) {
364
- throw new RangeError("At most 100000 results can be returned per call");
365
- }
366
- this.params = {};
367
- this.params["uriWgtListPage"] = page;
368
- this.params["uriWgtListCount"] = count;
369
- this.params["uriWgtListSortBy"] = sortBy;
370
- this.params["uriWgtListSortByAsc"] = sortByAsc;
371
- }
372
-
373
- public set page(page) {
374
- if (page < 1) {
375
- throw new RangeError("Page has to be >= 1");
376
- }
377
- _.set(this.params, "uriWgtListPage", page);
378
- }
379
- }
380
-
381
- /**
382
- * @class RequestEventsTimeAggr
383
- * Return time distribution of resulting events.
384
- */
385
- export class RequestEventsTimeAggr extends RequestEvents {
386
- public resultType = "timeAggr";
387
- }
388
-
389
- /**
390
- * Return keyword aggregate (tag cloud) on words in articles in resulting events.
391
- * @class RequestEventsTimeAggr
392
- */
393
- export class RequestEventsKeywordAggr extends RequestEvents {
394
- public resultType = "keywordAggr";
395
- public params;
396
- /**
397
- * @param lang: in which language to produce the list of top keywords. If undefined, then compute on all articles
398
- */
399
- constructor(lang?) {
400
- super();
401
- this.params = {};
402
- if (!_.isUndefined(lang)) {
403
- this.params["keywordAggrLang"] = lang;
404
- }
405
- }
406
- }
407
-
408
- /**
409
- * @class RequestEventsLocAggr
410
- * Return aggregate of locations of resulting events.
411
- */
412
- export class RequestEventsLocAggr extends RequestEvents {
413
- public resultType = "locAggr";
414
- public params;
415
- constructor(args: EventRegistryStatic.QueryEvents.RequestEventsLocAggrArguments = {}) {
416
- super();
417
- const {
418
- eventsSampleSize = 100000,
419
- returnInfo = new ReturnInfo(),
420
- ...unsupported
421
- } = args;
422
- if (!_.isEmpty(unsupported)) {
423
- console.warn(`RequestEventsLocAggr: Unsupported parameters detected: ${JSON.stringify(unsupported)}. Please check the documentation.`);
424
- }
425
- if (eventsSampleSize > 100000) {
426
- throw new RangeError("At most 100000 results can be used for computing");
427
- }
428
- this.params = {};
429
- this.params["locAggrSampleSize"] = eventsSampleSize;
430
- this.params = _.extend({}, this.params, returnInfo.getParams("locAggr"));
431
- }
432
- }
433
-
434
- /**
435
- * @class RequestEventsLocTimeAggr
436
- * Return aggregate of locations and times of resulting events.
437
- */
438
- export class RequestEventsLocTimeAggr extends RequestEvents {
439
- public resultType = "locTimeAggr";
440
- public params;
441
- constructor(args: EventRegistryStatic.QueryEvents.RequestEventsLocTimeAggrArguments = {}) {
442
- super();
443
- const {
444
- eventsSampleSize = 100000,
445
- returnInfo = new ReturnInfo(),
446
- ...unsupported
447
- } = args;
448
- if (!_.isEmpty(unsupported)) {
449
- console.warn(`RequestEventsLocTimeAggr: Unsupported parameters detected: ${JSON.stringify(unsupported)}. Please check the documentation.`);
450
- }
451
- if (eventsSampleSize > 100000) {
452
- throw new RangeError("At most 100000 results can be used for computing");
453
- }
454
- this.params = {};
455
- this.params["locTimeAggrSampleSize"] = eventsSampleSize;
456
- this.params = _.extend({}, this.params, returnInfo.getParams("locTimeAggr"));
457
- }
458
- }
459
-
460
- /**
461
- * @class RequestEventsConceptAggr
462
- * Compute which concept are the most frequently occurring in the list of resulting events.
463
- */
464
- export class RequestEventsConceptAggr extends RequestEvents {
465
- public resultType = "conceptAggr";
466
- public params;
467
- constructor(args: EventRegistryStatic.QueryEvents.RequestEventsConceptAggrArguments = {}) {
468
- super();
469
- const { conceptCount = 20, eventsSampleSize = 100000, returnInfo = new ReturnInfo() } = args;
470
- if (conceptCount > 200) {
471
- throw new RangeError("At most 200 top concepts can be returned");
472
- }
473
- if (eventsSampleSize > 300000) {
474
- throw new RangeError("At most 300000 results can be used for computing");
475
- }
476
- this.params = {};
477
- this.params["conceptAggrConceptCount"] = conceptCount;
478
- this.params["conceptAggrSampleSize"] = eventsSampleSize;
479
- this.params = _.extend({}, this.params, returnInfo.getParams("conceptAggr"));
480
- }
481
- }
482
-
483
- /**
484
- * @class RequestEventsConceptGraph
485
- * Compute which concept pairs frequently co-occur together in the resulting events.
486
- */
487
- export class RequestEventsConceptGraph extends RequestEvents {
488
- public resultType = "conceptGraph";
489
- public params;
490
- constructor(args: EventRegistryStatic.QueryEvents.RequestEventsConceptGraphArguments = {}) {
491
- super();
492
- const { conceptCount = 25, linkCount = 150, eventsSampleSize = 50000, returnInfo = new ReturnInfo() } = args;
493
- if (conceptCount > 1000) {
494
- throw new RangeError("At most 1000 top concepts can be returned");
495
- }
496
- if (linkCount > 2000) {
497
- throw new RangeError("At most 2000 links between concepts can be returned");
498
- }
499
- if (eventsSampleSize > 300000) {
500
- throw new RangeError("At most 300000 results can be used for computing");
501
- }
502
- this.params = {};
503
- this.params["conceptGraphConceptCount"] = conceptCount;
504
- this.params["conceptGraphLinkCount"] = linkCount;
505
- this.params["conceptGraphSampleSize"] = eventsSampleSize;
506
- this.params = _.extend({}, this.params, returnInfo.getParams("conceptGraph"));
507
- }
508
- }
509
-
510
- /**
511
- * @class RequestEventsConceptMatrix
512
- * Get a matrix of concepts and their dependencies.
513
- * For individual concept pairs return how frequently
514
- * they co-occur in the resulting events and how "surprising" this is,
515
- * based on the frequency of individual concepts.
516
- */
517
- export class RequestEventsConceptMatrix extends RequestEvents {
518
- public resultType = "conceptMatrix";
519
- public params;
520
- constructor(args: EventRegistryStatic.QueryEvents.RequestEventsConceptMatrixArguments = {}) {
521
- super();
522
- const { conceptCount = 25, measure = "pmi", eventsSampleSize = 100000, returnInfo = new ReturnInfo() } = args;
523
- if (conceptCount > 200) {
524
- throw new RangeError("At most 200 top concepts can be returned");
525
- }
526
- if (eventsSampleSize > 300000) {
527
- throw new RangeError("At most 300000 results can be used for computing");
528
- }
529
- this.params = {};
530
- this.params["conceptMatrixConceptCount"] = conceptCount;
531
- this.params["conceptMatrixMeasure"] = measure;
532
- this.params["conceptMatrixSampleSize"] = eventsSampleSize;
533
- this.params = _.extend({}, this.params, returnInfo.getParams("conceptMatrix"));
534
- }
535
- }
536
-
537
- /**
538
- * @class RequestEventsConceptTrends
539
- * Return a list of top trending concepts and their daily trending info over time
540
- */
541
- export class RequestEventsConceptTrends extends RequestEvents {
542
- public resultType = "conceptTrends";
543
- public params;
544
- constructor(args: EventRegistryStatic.QueryEvents.RequestEventsConceptTrendsArguments = {}) {
545
- super();
546
- const { conceptCount = 10, conceptUris = [], returnInfo = new ReturnInfo() } = args;
547
- if (conceptCount > 50) {
548
- throw new RangeError("At most 50 top concepts can be returned");
549
- }
550
- this.params = {};
551
- this.params["conceptTrendsConceptCount"] = conceptCount;
552
- if (!_.isEmpty(conceptUris)) {
553
- this.params["conceptTrendsConceptUri"] = conceptUris;
554
- }
555
- this.params = _.extend({}, this.params, returnInfo.getParams("conceptTrends"));
556
- }
557
- }
558
-
559
- /**
560
- * @class RequestEventsSourceAggr
561
- * Return top news sources that report about the events that match the search conditions
562
- */
563
- export class RequestEventsSourceAggr extends RequestEvents {
564
- public resultType = "sourceAggr";
565
- public params;
566
- constructor(args: EventRegistryStatic.QueryEvents.RequestEventsSourceAggrArguments = {}) {
567
- super();
568
- const { sourceCount = 30, eventsSampleSize = 50000, returnInfo = new ReturnInfo() } = args;
569
- if (sourceCount > 200) {
570
- throw new RangeError("At most 200 top sources can be returned");
571
- }
572
- if (eventsSampleSize > 100000) {
573
- throw new RangeError("At most 100000 results can be used for computing");
574
- }
575
- this.params = {};
576
- this.params["sourceAggrSourceCount"] = sourceCount;
577
- this.params["sourceAggrSampleSize"] = eventsSampleSize;
578
- this.params = _.extend({}, this.params, returnInfo.getParams("sourceAggr"));
579
- }
580
- }
581
-
582
- /**
583
- * @class RequestEventsDateMentionAggr
584
- * Return events and the dates that are mentioned in articles about these events
585
- */
586
- export class RequestEventsDateMentionAggr extends RequestEvents {
587
- public resultType = "dateMentionAggr";
588
- public params;
589
- constructor(args: EventRegistryStatic.QueryEvents.RequestEventsDateMentionAggrArguments = {}) {
590
- super();
591
- const {
592
- minDaysApart = 0,
593
- minDateMentionCount = 5,
594
- eventsSampleSize = 100000,
595
- returnInfo = new ReturnInfo(),
596
- } = args;
597
- if (eventsSampleSize > 300000) {
598
- throw new RangeError("At most 300000 results can be used for computing");
599
- }
600
- this.params = {};
601
- this.params["dateMentionAggrMinDaysApart"] = minDaysApart;
602
- this.params["dateMentionAggrMinDateMentionCount"] = minDateMentionCount;
603
- this.params["dateMentionAggrSampleSize"] = eventsSampleSize;
604
- this.params = _.extend({}, this.params, returnInfo.getParams("dateMentionAggr"));
605
- }
606
- }
607
-
608
- /**
609
- * @class RequestEventsEventClusters
610
- * Return hierarchical clustering of events into smaller clusters. 2-means clustering is applied on each node in the tree
611
- */
612
- export class RequestEventsEventClusters extends RequestEvents {
613
- public resultType = "eventClusters";
614
- public params;
615
- constructor(args: EventRegistryStatic.QueryEvents.RequestEventsEventClustersArguments = {}) {
616
- super();
617
- const { keywordCount = 30, maxEventsToCluster = 10000, returnInfo = new ReturnInfo() } = args;
618
- if (keywordCount > 100) {
619
- throw new RangeError("At most 100 keywords can be reported in each of the clusters");
620
- }
621
- if (maxEventsToCluster > 10000) {
622
- throw new RangeError("At most 10000 events can be clustered together");
623
- }
624
- this.params = {};
625
- this.params["eventClustersKeywordCount"] = keywordCount;
626
- this.params["eventClustersMaxEventsToCluster"] = maxEventsToCluster;
627
- this.params = _.extend({}, this.params, returnInfo.getParams("eventClusters"));
628
- }
629
- }
630
-
631
- /**
632
- * @class RequestEventsCategoryAggr
633
- * Return distribution of events into dmoz categories.
634
- */
635
- export class RequestEventsCategoryAggr extends RequestEvents {
636
- public resultType = "categoryAggr";
637
- public params;
638
- constructor(returnInfo = new ReturnInfo()) {
639
- super();
640
- this.params = returnInfo.getParams("categoryAggr");
641
- }
642
- }
643
-
644
- /**
645
- * @class RequestEventsRecentActivity
646
- * Return a list of recently changed events that match search conditions.
647
- */
648
- export class RequestEventsRecentActivity extends RequestEvents {
649
- public resultType = "recentActivity";
650
- public params;
651
- constructor(args: EventRegistryStatic.QueryEvents.RequestEventsRecentActivityArguments = {}) {
652
- super();
653
- const {
654
- maxEventCount = 50,
655
- updatesAfterTm,
656
- updatesAfterMinsAgo,
657
- mandatoryLocation = true,
658
- minAvgCosSim = 0,
659
- returnInfo = undefined,
660
- } = args;
661
- if (maxEventCount > 2000) {
662
- throw new RangeError("At most 2000 events can be returned");
663
- }
664
- if (!_.isUndefined(updatesAfterTm) && !_.isUndefined(updatesAfterMinsAgo)) {
665
- throw new Error("You should specify either updatesAfterTm or updatesAfterMinsAgo parameter, but not both");
666
- }
667
- this.params = {};
668
- this.params["recentActivityEventsMaxEventCount"] = maxEventCount;
669
- this.params["recentActivityEventsMandatoryLocation"] = mandatoryLocation;
670
-
671
- if (!_.isUndefined(updatesAfterTm)) {
672
- this.params["recentActivityEventsUpdatesAfterTm"] = QueryParamsBase.encodeDateTime(updatesAfterTm);
673
- }
674
-
675
- if (!_.isUndefined(updatesAfterMinsAgo)) {
676
- this.params["recentActivityEventsUpdatesAfterMinsAgo"] = updatesAfterMinsAgo;
677
- }
678
-
679
- this.params["recentActivityEventsMinAvgCosSim"] = minAvgCosSim;
680
- if (!!returnInfo) {
681
- this.params = _.extend({}, this.params, returnInfo.getParams("recentActivityEvents"));
682
- }
683
- }
684
- }