def __init__(self, credFile='egovbench_credentials.ini', confFile='egovbench_config.ini'): credparser = SafeConfigParser() credparser.read(credFile) self.access_token = credparser.get('FacebookCredentials', 'access_token') confparser2 = SafeConfigParser() confparser2.read(confFile) self.crawllimit = int(confparser2.get('CrawlerConfig', 'crawllimit')) logger = logging.getLogger() logger.setLevel(logging.DEBUG) if not logger.handlers: formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s') fh = RotatingFileHandler('logs/facebook/egovbench_facebook.log', maxBytes=20971520, backupCount=5) fh.setLevel(logging.DEBUG) fh.setFormatter(formatter) logger.addHandler(fh) ch = logging.StreamHandler() ch.setLevel(logging.INFO) ch.setFormatter(formatter) logger.addHandler(ch) self.p = Pusher() self.fc = FacebookCollector() self.fmc = FacebookMongoConnector()
def getPostTypeScoreDocument(self): update_document = {} post_types = self.fmc.getPostTypeDistinct('post_type') for post_type in post_types: posttypeattribute = {'post_type': post_type} super(FacebookScorer, self).__init__( posttypeattribute, FacebookMongoConnector(), 'post_reactions.like', 'post_commentCount', 'post_shareCount', 'page_id', 'post_type' ) self.prompt('{} Creating score document . . .'.format(json.dumps(self.filter_dict))) update_document['_id'] = posttypeattribute['post_type'] update_document['result.scores'] = {} update_document['result.scores']['engagement_index_score'] = self.getEngagementIndexScore() self.prompt('{} Score document created!'.format(json.dumps(self.filter_dict))) self.mongo_connector_class.updatePostTypeResult(update_document)
def getAccountPostTypeScoreDocument(self): update_document = {} post_types = self.fmc.getPostTypeDistinct('post_type') for post_type in post_types: self.filter_dict.pop('post_type', None) posttypeattribute = {'post_type': post_type} posttypeattribute.update(self.filter_dict) super(FacebookScorer, self).__init__( posttypeattribute, FacebookMongoConnector(), 'post_reactions.like', 'post_commentCount', 'post_shareCount', 'page_id', 'post_type' ) self.prompt('{} Creating score document . . .'.format(json.dumps(self.filter_dict))) update_document['page_id'] = self.filter_dict['page_id'].lower() update_document['post_type_result.%s.scores' % (post_type)] = {} update_document['post_type_result.%s.scores' % (post_type)]['engagement_index_score'] = self.getEngagementIndexScore() self.prompt('{} Score document created!'.format(json.dumps(self.filter_dict))) return update_document
def __init__(self): logger = logging.getLogger() logger.setLevel(logging.DEBUG) if not logger.handlers: formatter = logging.Formatter( '%(asctime)s - %(levelname)s - %(message)s') logpath = '/home/addi/egovbench/logs/facebook/egovbench_facebooktrigger.log' try: fh = RotatingFileHandler(logpath, maxBytes=20971520, backupCount=5) fh.setLevel(logging.DEBUG) fh.setFormatter(formatter) logger.addHandler(fh) ch = logging.StreamHandler() ch.setLevel(logging.INFO) ch.setFormatter(formatter) logger.addHandler(ch) except FileNotFoundError: self.createdirectory(logpath) self.fmc = FacebookMongoConnector()
def __init__(self, filterDict, confFile='/home/addi/egovbench/apps/pythons/egovbench_config.ini'): super(FacebookScorer, self).__init__( filterDict, FacebookMongoConnector(), 'post_reactions.like', 'post_commentCount', 'post_shareCount', 'page_id', 'post_type' ) self.filter_dict = filterDict self.fmc = FacebookMongoConnector() # Mengambil skor sentimen reaction dari file egovbench_config.ini self.confparser = SafeConfigParser() self.confparser.read(confFile)
def __init__(self): self.fp = FacebookParser() self.fmc = FacebookMongoConnector()
def __init__(self): self.fp = FacebookParser() self.fmc = FacebookMongoConnector() self.fkp = FacebookKafkaPost() self.fkc = FacebookKafkaComment()