def load(self): try: tag_recommendation_data = loadFromJson( RECOMMENDATION_DATA_DIR + 'Current_database_and_class_names.json') DATABASE = tag_recommendation_data['database'] CLASSES = tag_recommendation_data['classes'] self.cbtr = CommunityBasedTagRecommender(dataset=DATABASE, classes=CLASSES) self.cbtr.load_recommenders() except: self.cbtr = None logger.info( "No computed matrices were found, recommendation system not loading for the moment (but service listening for data to come)." ) try: self.index_stats = loadFromJson(RECOMMENDATION_DATA_DIR + 'Current_index_stats.json') logger.info("Matrices computed out of information from %i sounds" % self.index_stats['n_sounds_in_matrix']) except Exception, e: print e self.index_stats = { 'n_sounds_in_matrix': 0, }
def load(self): try: tag_recommendation_data = loadFromJson(RECOMMENDATION_DATA_DIR + 'Current_database_and_class_names.json') DATABASE = tag_recommendation_data['database'] CLASSES = tag_recommendation_data['classes'] self.cbtr = CommunityBasedTagRecommender(dataset=DATABASE, classes=CLASSES) self.cbtr.load_recommenders() except: self.cbtr = None logger.info("No computed matrices were found, recommendation system not loading for the moment (but service listening for data to come).") try: self.index_stats = loadFromJson(RECOMMENDATION_DATA_DIR + 'Current_index_stats.json') logger.info("Matrices computed out of information from %i sounds" % self.index_stats['n_sounds_in_matrix']) except Exception as e: print(e) self.index_stats = { 'n_sounds_in_matrix': 0, } try: self.index = loadFromJson(RECOMMENDATION_DATA_DIR + 'Index.json') self.index_stats['biggest_id_in_index'] = max([int(key) for key in self.index.keys()]) self.index_stats['n_sounds_in_index'] = len(self.index.keys()) except Exception as e: logger.info("Index file not present. Listening for indexing data from appservers.") self.index_stats['biggest_id_in_index'] = 0 self.index_stats['n_sounds_in_index'] = 0 self.index = dict()