eventregistry 8.9.1 → 8.10.1

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/src/types.d.ts CHANGED
@@ -2,6 +2,7 @@ import { QueryItems } from "./base";
2
2
  import { BaseQuery, CombinedQuery} from "./query";
3
3
  import { QueryArticles, RequestArticles } from "./queryArticles";
4
4
  import { RequestEvents } from "./queryEvents";
5
+ import { RequestMentions } from "./queryMentions";
5
6
  import { ReturnInfo } from "./returnInfo";
6
7
 
7
8
  /**
@@ -47,7 +48,7 @@ export module EventRegistryStatic {
47
48
  */
48
49
  repeatFailedRequestCount?: number;
49
50
  /**
50
- * if true, additional info about query times etc. will be printed to console
51
+ * if true, additional info about errors etc. will be printed to console
51
52
  */
52
53
  verboseOutput?: boolean;
53
54
  /**
@@ -1104,6 +1105,150 @@ export module EventRegistryStatic {
1104
1105
  returnInfo?: ReturnInfo;
1105
1106
  }
1106
1107
  }
1108
+ export namespace QueryMentions {
1109
+ export interface Arguments {
1110
+ eventTypeUri?: string | string[] | QueryItems;
1111
+ keywords?: string | string[] | QueryItems;
1112
+ conceptUri?: string | string[] | QueryItems;
1113
+ categoryUri?: string | string[] | QueryItems;
1114
+ sourceUri?: string | string[] | QueryItems;
1115
+ sourceLocationUri?: string | string[] | QueryItems;
1116
+ sourceGroupUri?: string | string[] | QueryItems;
1117
+ industryUri?: string | string[] | QueryItems;
1118
+ locationUri?: string | string[] | QueryItems;
1119
+ lang?: string | string[];
1120
+ dateStart?: string | Date;
1121
+ dateEnd?: string | Date;
1122
+ ignoreEventTypeUri?: string | string[] | QueryItems;
1123
+ ignoreKeywords?: string | string[] | QueryItems;
1124
+ ignoreConceptUri?: string | string[] | QueryItems;
1125
+ ignoreCategoryUri?: string | string[] | QueryItems;
1126
+ ignoreSourceUri?: string | string[] | QueryItems;
1127
+ ignoreSourceLocationUri?: string | string[] | QueryItems;
1128
+ ignoreSourceGroupUri?: string | string[] | QueryItems;
1129
+ ignoreIndustryUri?: string | string[] | QueryItems;
1130
+ ignoreLocationUri?: string | string[] | QueryItems;
1131
+ ignoreLang?: string | string[];
1132
+ showDuplicates?: boolean;
1133
+ startSourceRankPercentile?: number;
1134
+ endSourceRankPercentile?: number;
1135
+ minSentiment?: number;
1136
+ maxSentiment?: number;
1137
+ requestedResult?: RequestMentions;
1138
+ }
1139
+ export interface IteratorArguments extends Arguments {
1140
+ }
1141
+
1142
+ export interface RequestMentionsUriWgtListArguments {
1143
+ /**
1144
+ * page of the results to return (1, 2, ...)
1145
+ */
1146
+ page?: number;
1147
+ /**
1148
+ * number of results to return per page
1149
+ */
1150
+ count?: number;
1151
+ /**
1152
+ * how should the resulting events be sorted. Options:
1153
+ * - none (no specific sorting),
1154
+ * - date (by event date),
1155
+ * - rel (relevance to the query),
1156
+ * - size (number of articles),
1157
+ * - socialScore (amount of shares in social media)
1158
+ */
1159
+ sortBy?: "none" | "rel" | "date" | "size" | "socialScore";
1160
+ /**
1161
+ * should the results be sorted in ascending order (true) or descending (false)
1162
+ */
1163
+ sortByAsc?: boolean;
1164
+ }
1165
+
1166
+ export interface RequestMentionsConceptAggrArguments {
1167
+ /**
1168
+ * number of top concepts to return
1169
+ */
1170
+ conceptCount?: number;
1171
+ /**
1172
+ * on what sample of results should the aggregate be computed
1173
+ */
1174
+ mentionsSampleSize?: number;
1175
+ /**
1176
+ * what details about the concepts should be included in the returned information
1177
+ */
1178
+ returnInfo?: ReturnInfo;
1179
+ /**
1180
+ * how should the top concepts be computed. Possible values are
1181
+ * "importance" (takes into account how frequently a concept is mentioned and how relevant it is in an mention),
1182
+ * "frequency" (ranks the concepts simply by how frequently the concept is mentioned in the results) and
1183
+ * "uniqueness" (computes what are the top concepts that are frequently mentioned in the results of your search query but less frequently mentioned in the news in general)
1184
+ */
1185
+ conceptScoring?: "importance" | "frequency" | "uniqueness"
1186
+ /**
1187
+ * if you wish to limit the number of top concepts per type (person, org, loc, wiki) then set this to some number.
1188
+ * If you want to get equal number of concepts for each type then set conceptCountPerType to conceptCount/4 (since there are 4 concept types)
1189
+ */
1190
+ conceptCountPerType?: number;
1191
+ }
1192
+
1193
+ export interface RequestMentionsCategoryAggrArguments {
1194
+ mentionsSampleSize?: number;
1195
+ returnInfo?: ReturnInfo;
1196
+ }
1197
+
1198
+ export interface RequestMentionsSourceAggrArguments {
1199
+ sourceCount?: number;
1200
+ normalizeBySourceArts?: boolean;
1201
+ returnInfo?: ReturnInfo;
1202
+ }
1203
+
1204
+ export interface RequestMentionsKeywordAggrArguments {
1205
+ mentionsSampleSize?: number;
1206
+ }
1207
+
1208
+ export interface RequestMentionsConceptGraphArguments {
1209
+ /**
1210
+ * number of top sources to return
1211
+ */
1212
+ conceptCount?: number;
1213
+ linkCount?: number;
1214
+ /**
1215
+ * on what sample of results should the aggregate be computed
1216
+ */
1217
+ mentionsSampleSize?: number;
1218
+ /**
1219
+ * what details about the concepts should be included in the returned information
1220
+ */
1221
+ returnInfo?: ReturnInfo;
1222
+ skipQueryConcepts?: boolean;
1223
+ }
1224
+
1225
+ export interface RequestMentionsRecentActivityArguments {
1226
+ /**
1227
+ * max mentions to return
1228
+ */
1229
+ maxMentionCount?: number;
1230
+ updatesAfterUri?: string;
1231
+ /**
1232
+ * the time after which the events were added/updated (returned by previous call to the same method)
1233
+ */
1234
+ updatesAfterTm?: string | Date;
1235
+ /**
1236
+ * how many minutes into the past should we check (set either this or updatesAfterTm property, but not both)
1237
+ */
1238
+ updatesAfterMinsAgo?: number;
1239
+ updatesUntilTm?: string | Date;
1240
+ updatesUntilMinsAgo?: number;
1241
+ /**
1242
+ * return only events that have a geographic location assigned to them
1243
+ */
1244
+ mandatorySourceLocation?: boolean;
1245
+ /**
1246
+ * what details should be included in the returned information
1247
+ */
1248
+ returnInfo?: ReturnInfo;
1249
+ }
1250
+ }
1251
+
1107
1252
  export namespace QueryEvents {
1108
1253
  export interface Arguments {
1109
1254
  /**
@@ -17,7 +17,7 @@ describe("Auto Suggest", () => {
17
17
 
18
18
  it("should return a news source", async (done) => {
19
19
  expect(await er.getNewsSourceUri("nytimes")).toEqual("nytimes.com");
20
- expect(await er.getNewsSourceUri("bbc")).toEqual("bbc.com");
20
+ expect(await er.getNewsSourceUri("bbc")).toEqual("bbc.co.uk");
21
21
  done();
22
22
  });
23
23
 
@@ -75,6 +75,7 @@ describe("Info", () => {
75
75
  const response = await er.execQuery(q);
76
76
  expect(_.size(response)).toBe(_.size(uriList), `Expected ${_.size(uriList)} categories`);
77
77
  _.each(response, (item) => {
78
+ if (_.has(item, "error")) return;
78
79
  expect(_.has(item, "uri")).toBeTruthy("Category uri is missing");
79
80
  expect(_.has(item, "trendingScore")).toBeTruthy("Category trending score is missing");
80
81
  });
@@ -132,7 +132,7 @@ describe("Query Articles", () => {
132
132
  const returnInfo = new ReturnInfo({articleInfo: utils.articleInfo});
133
133
  const q = new QueryArticlesIter(er, {keywords: "home", keywordsLoc: "body", lang: "eng", returnInfo: returnInfo, maxItems: 50});
134
134
  q.execQuery((item) => {
135
- expect(item).toContainBodyText("home");
135
+ expect(_.deburr(_.toLower(_.get(item, "body")))).toContain("home");
136
136
  }, (errorMessage) => {
137
137
  if (errorMessage) {
138
138
  console.error(errorMessage);
@@ -145,11 +145,11 @@ describe("Query Articles", () => {
145
145
  }
146
146
  });
147
147
 
148
- it("should return list of articles with keyword body search ('jack')", (done) => {
148
+ it("should return list of articles with keyword body search ('Jack')", (done) => {
149
149
  try {
150
- const q = new QueryArticlesIter(er, {keywords: "jack", keywordsLoc: "body", lang: "eng", returnInfo: new ReturnInfo({articleInfo: utils.articleInfo}), maxItems: 50});
150
+ const q = new QueryArticlesIter(er, {keywords: "Jack", keywordsLoc: "body", lang: "eng", returnInfo: new ReturnInfo({articleInfo: utils.articleInfo}), maxItems: 50});
151
151
  q.execQuery((item) => {
152
- expect(item).toContainBodyText("jack");
152
+ expect(item).toContainBodyText("Jack");
153
153
  }, (errorMessage) => {
154
154
  if (errorMessage) {
155
155
  console.error(errorMessage);
@@ -435,6 +435,7 @@ describe("Query Articles", () => {
435
435
  expect(_.has(sourceInfo, "counts.total")).toBeTruthy("Counts should contain a total");
436
436
  }
437
437
  for (const country of _.get(response, "sourceAggr.countsPerCountry")) {
438
+ if (_.get(country, "uri") === "http://en.wikipedia.org/wiki/Australia_(continent)") return;
438
439
  expect(_.get(country, "type")).toEqual("loc", "Country should be a location");
439
440
  expect(_.get(country, "frequency")).toBeGreaterThan(0);
440
441
  }
@@ -46,7 +46,7 @@ describe("Query Articles Complex", () => {
46
46
  });
47
47
 
48
48
  it("should test keywords (3)", (done) => {
49
- const baseQuery = new BaseQuery({keyword: "home", keywordLoc: "body"});
49
+ const baseQuery = new BaseQuery({keyword: "home", lang: "eng", keywordLoc: "body"});
50
50
  const cq1 = new ComplexArticleQuery(baseQuery);
51
51
  const artIter = QueryArticlesIter.initWithComplexQuery(er, cq1, {returnInfo: utils.returnInfo, maxItems: 20});
52
52
  artIter.execQuery((item) => {
@@ -244,12 +244,11 @@ describe("Query Articles Complex", () => {
244
244
  const cq1 = new ComplexArticleQuery(new BaseQuery({dateStart: "2016-03-05", dateEnd: "2017-03-06", exclude: new BaseQuery({categoryUri})}));
245
245
  const cq2 = new ComplexArticleQuery(CombinedQuery.AND([
246
246
  new BaseQuery({ dateStart: "2016-03-05", dateEnd: "2017-05-05" }),
247
- new BaseQuery({ dateStart: "2017-03-05" }),
248
247
  new BaseQuery({ dateStart: "2016-10-05" }),
249
248
  new BaseQuery({ dateEnd: "2017-04-05" }),
250
249
  new BaseQuery({ dateEnd: "2017-03-06" }),
251
- ], new BaseQuery({categoryUri: await er.getCategoryUri("Business")})));
252
- const q = new QueryArticles({dateStart: "2017-03-05", dateEnd: "2017-03-06", ignoreCategoryUri: categoryUri});
250
+ ], new BaseQuery({categoryUri})));
251
+ const q = new QueryArticles({dateStart: "2016-03-05", dateEnd: "2017-03-06", ignoreCategoryUri: categoryUri});
253
252
  const listRes1 = await utils.getArticlesQueryUriListForComplexQuery(er, cq1);
254
253
  const listRes2 = await utils.getArticlesQueryUriListForComplexQuery(er, cq2);
255
254
  const listRes3 = await utils.getQueryUriListForQueryArticles(er, q);
@@ -38,27 +38,27 @@ describe("Query Event", () => {
38
38
  });
39
39
 
40
40
  it("should test event articles filtering", async (done) => {
41
- const q1 = new QueryEventArticlesIter(er, "eng-4167169");
41
+ const q1 = new QueryEventArticlesIter(er, "ind-9586");
42
42
  const counts1 = await q1.count();
43
- const counts2 = await (new QueryEventArticlesIter(er, "eng-4167169", {lang: "eng"})).count();
43
+ const counts2 = await (new QueryEventArticlesIter(er, "ind-9586", {lang: "eng"})).count();
44
44
  expect(counts1).not.toEqual(counts2, "Comparison 1 failed!");
45
- const counts3 = await (new QueryEventArticlesIter(er, "eng-4167169", {conceptUri: await er.getConceptUri("United States")})).count();
45
+ const counts3 = await (new QueryEventArticlesIter(er, "ind-9586", {conceptUri: await er.getConceptUri("United States")})).count();
46
46
  expect(counts1).not.toEqual(counts3, "Comparison 2 failed!");
47
- const counts4 = await (new QueryEventArticlesIter(er, "eng-4167169", {keywords: "United States"})).count();
47
+ const counts4 = await (new QueryEventArticlesIter(er, "ind-9586", {keywords: "United States"})).count();
48
48
  expect(counts1).not.toEqual(counts4, "Comparison 3 failed!");
49
- const counts5 = await (new QueryEventArticlesIter(er, "eng-4167169", {sourceUri: await er.getNewsSourceUri("Washington Post")})).count();
49
+ const counts5 = await (new QueryEventArticlesIter(er, "ind-9586", {sourceUri: await er.getNewsSourceUri("Washington Post")})).count();
50
50
  expect(counts1).not.toEqual(counts5, "Comparison 4 failed!");
51
- const counts6 = await (new QueryEventArticlesIter(er, "eng-4167169", {lang: "eng", conceptUri: await er.getConceptUri("United States")})).count();
51
+ const counts6 = await (new QueryEventArticlesIter(er, "ind-9586", {lang: "eng", conceptUri: await er.getConceptUri("United States")})).count();
52
52
  expect(counts1).not.toEqual(counts6, "Comparison 5 failed!");
53
53
  let count = 0;
54
54
  q1.execQuery(() => {
55
55
  count++;
56
56
  }, async () => {
57
57
  expect(counts1).toEqual(count, "Comparison 6 failed!");
58
- const q = new QueryEvent("eng-4167169");
58
+ const q = new QueryEvent("ind-9586");
59
59
  q.setRequestedResult(new RequestEventArticles({lang: "eng", conceptUri: await er.getConceptUri("United States")}));
60
60
  const response = await er.execQuery(q);
61
- expect(counts6).toEqual(_.get(response, "eng-4167169.articles.totalResults", 0), "Comparison 7 failed!");
61
+ expect(counts6).toEqual(_.get(response, "ind-9586.articles.totalResults", 0), "Comparison 7 failed!");
62
62
  done();
63
63
  });
64
64
  });
@@ -333,6 +333,7 @@ describe("Query Events", () => {
333
333
  expect(_.has(sourceInfo, "counts.total")).toBeTruthy("Counts should contain total");
334
334
  });
335
335
  _.each(_.get(response, "sourceAggr.countsPerCountry"), (country) => {
336
+ if (_.get(country, "uri") === "http://en.wikipedia.org/wiki/Australia_(continent)") return;
336
337
  expect(_.get(country, "type")).toEqual("loc", "Country should be a location");
337
338
  expect(_.get(country, "frequency")).toBeGreaterThan(0);
338
339
  });
@@ -7,7 +7,7 @@ describe("Topic Page", () => {
7
7
 
8
8
  async function createTopicPage() {
9
9
  const q = new TopicPage(er);
10
- await q.loadTopicPageFromER("f1cfb96c-941b-4fbe-8619-bafba42a8053");
10
+ await q.loadTopicPageFromER("df793a2e-615a-4630-8632-bb117e64886f");
11
11
  return q;
12
12
  }
13
13
 
@@ -15,9 +15,9 @@ describe("Topic Page", () => {
15
15
  const q = await createTopicPage();
16
16
  const uris: Set<string> = new Set();
17
17
  for (const page of _.range(1, 20)) {
18
- const articles = await q.getArticles({page: page, dataType: ["news", "blog"], sortBy: "rel"})
18
+ const response = await q.getArticles({page: page, dataType: ["news", "blog"], sortBy: "rel"})
19
19
  let rel = Number.MAX_SAFE_INTEGER;
20
- for (const {uri, wgt} of articles) {
20
+ for (const {uri, wgt} of _.get(response, "articles.results", [])) {
21
21
  expect(wgt).toBeLessThanOrEqual(rel);
22
22
  rel = wgt;
23
23
  expect(uris.has(uri)).toBeFalsy();
@@ -31,9 +31,9 @@ describe("Topic Page", () => {
31
31
  const q = await createTopicPage();
32
32
  const uris: Set<string> = new Set();
33
33
  for (const page of _.range(1, 20)) {
34
- const events = await q.getEvents({page: page, sortBy: "rel"})
34
+ const response = await q.getEvents({page: page, sortBy: "rel"})
35
35
  let rel = Number.MAX_SAFE_INTEGER;
36
- for (const {uri, wgt} of events) {
36
+ for (const {uri, wgt} of _.get(response, "events.results", [])) {
37
37
  expect(wgt).toBeLessThanOrEqual(rel);
38
38
  rel = wgt;
39
39
  expect(uris.has(uri)).toBeFalsy();
@@ -57,8 +57,8 @@ describe("Topic Page", () => {
57
57
  const conceptInfo = new ConceptInfoFlags({maxConceptsPerType: 500});
58
58
  const returnInfo = new ReturnInfo({articleInfo, conceptInfo});
59
59
  for (const page of _.range(1, 10)) {
60
- const articles = await topic.getArticles({page, returnInfo});
61
- for (const {concepts = [], categories = []} of articles) {
60
+ const response = await topic.getArticles({page, returnInfo});
61
+ for (const {concepts = [], categories = []} of _.get(response, "articles.results", [])) {
62
62
  let foundConcept = false;
63
63
  let foundCategory = false;
64
64
  for (const { uri } of concepts) {
@@ -44,6 +44,7 @@ export class Utils {
44
44
  location: true,
45
45
  extractedDates: true,
46
46
  socialScore: true,
47
+ duplicateList: true,
47
48
  });
48
49
  this.sourceInfo = new SourceInfoFlags({ description: true,
49
50
  location: true,
@@ -331,7 +332,7 @@ export class Utils {
331
332
  }
332
333
 
333
334
  private doesContainText(text, searchQuery) {
334
- return _.includes(_.deburr(_.toLower(text)), _.deburr(_.toLower(searchQuery)));
335
+ return _.includes(_.deburr(text), _.deburr(searchQuery));
335
336
  }
336
337
  }
337
338