Skip to content

Number of mentions in news or social media

Gregor Leban edited this page Mar 5, 2017 · 3 revisions

Sometimes it might be valuable to know how often is a particular concept mentioned in the news or social media on a particular date. How often was, for example Barack Obama mentioned in the news in March 2015? Or, how often were articles about Ebola virus shared in social media in August 2014?

To obtain this type of information we can use the GetCounts() class. For computing popularity of Barack Obama in the news, we can use the following code:

from eventregistry import *
er = EventRegistry(apiKey = YOUR_API_KEY)
q = GetCounts(er.getConceptUri("Obama"),
              source = "news",
              startDate = "2015-03-01", endDate = "2015-03-31")
ret = er.execQuery(q)

The returned result would be something like:

{
    "http://en.wikipedia.org/wiki/Barack_Obama": [
        {
            "count": 1123,
            "date": "2015-03-01"
        },
        {
            "count": 1695,
            "date": "2015-03-02"
        },
        // remaining values
    ]
}

The parameters that are accepted by the GetCounts() class are:

  • uriOrUriList: concept/category uri or a list of uris
  • source: input source information from which to compute top trends. Options: news, social
  • type: what do the provided uris represent - concept or category
  • startDate: starting date from which to provide counts onward (either None, datetime.date or "YYYY-MM-DD")
  • endDate: ending date until which to provide counts (either None, datetime.date or "YYYY-MM-DD")
  • returnInfo: specify the details of the concepts/categories to return