Пример #1
0
def publish(app_id, source_id, publisher):
    """ Periodically called by a timer to publish events which contain the statistics of mentions and hashtags
    """

    graph = buildGraph(mentionsDict, "mention")
    if graph != None:
        event = rdfevents.RDFEvent(source_id,
                                   'text/n3',
                                   graph,
                                   application_id=app_id)
        print(event)
        publisher.publish(event)

    mentionsDict.clear()

    graph = buildGraph(hashtagsDict, "hashtag")
    if graph != None:
        event = rdfevents.RDFEvent(source_id,
                                   'text/n3',
                                   graph,
                                   application_id=app_id)
        print(event)
        publisher.publish(event)

    hashtagsDict.clear()
Пример #2
0
 def publish(self, graph):
     event = rdfevents.RDFEvent(self.source_id,
                                'text/n3',
                                graph,
                                application_id=self.app_id)
     print(event)
     self.publisher.publish(event)
Пример #3
0
 def publish_event(self):
     self.schedule_next_event()
     tweets = self.client.get_tweets(self.last_id)
     if len(tweets) > 0:
         print "Generating ", len(tweets), " events..."
         for tweet in tweets:
             n3rdf = self.toN3(tweet)
             event = rdfevents.RDFEvent(self.source_id,
                                        'text/n3',
                                        n3rdf,
                                        application_id=self.app_id)
             print event
             self.publisher.publish(event)
             self.last_id = tweet.id
     else:
         print "No new events to be generated..."
Пример #4
0
 def publish(self, source_id, graph):
     event = rdfevents.RDFEvent(source_id, 'text/n3', graph, application_id = self.app_id)
     ## print event
     self.publisher.publish(event)
     self.counter += 1