Beispiel #1
0
def getAllEREducationEvents(path):
    er = EventRegistry(host = "http://eventregistry.org", logging = True)
    q = QueryEvents()
    q.addConcept(er.getConceptUri("Education"))
    q.addRequestedResult(RequestEventsUriList())
    res = er.execQuery(q)
    obj = createStructFromDict(res)
    uris = obj.uriList

    l = len(uris)
    inserts = []
    tblEvents.purge()
    for i,uri in enumerate(uris):
        try:
            q = QueryEvent(uri)
            q.addRequestedResult(RequestEventInfo(["eng"]))   # get event information. concept labels should be in three langauges
            q.addRequestedResult(RequestEventArticles(0, 10))   # get 10 articles describing the event
            q.addRequestedResult(RequestEventKeywordAggr())     # get top keywords describing the event
            eventRes = er.execQuery(q)
            out = {}
            out['info'] =  eventRes[uri][u'info'][u'multiLingInfo']
            out['date'] =  eventRes[uri][u'info'][u'eventDate']
            out['uri'] = uri
            tblEvents.insert(out)
            #print i,l
        except:
            pass
Beispiel #2
0
def getERNews():
    # Loading credentials
    pwd = {}
    with open('pwd.json') as data_file:
        pwd = json.load(data_file)
    er = EventRegistry()
    er.login(pwd['er']['user'], pwd['er']['pass'])

    q = QueryArticles()     # we want to make a search for articles
    q.addKeyword("education")       # article should contain word apple
    q.addRequestedResult(RequestArticlesInfo(page=0, count = 10));  # get 30 articles that match the criteria
    res = er.execQuery(q)
    return res
def getERNewsRelated(text):
    er = EventRegistry()

    pwd = {}
    with open('pwd.json') as data_file:
        pwd = json.load(data_file)
    er = EventRegistry()
    er.login(pwd['er']['user'], pwd['er']['pass'])

    q = QueryArticles()     # we want to make a search for articles
    q.addKeyword(text)       # article should contain word apple
    q.addRequestedResult(RequestArticlesInfo(sortBy="date", sortByAsc = False, page=0, count=30));  # get 30 articles that match the criteria
    res = er.execQuery(q)
    return res