Esempio n. 1
0
def main():
    path = os.path.dirname(os.path.realpath(__file__))
    utils = Utils()
    settings = utils.load_settings()
    ##
    # add tools
    ##
    admin = Admin(settings['admin'])
    parser = argparse.ArgumentParser(prog='pool-cli')
    subparsers = parser.add_subparsers()
    ##
    # add subparser for tools
    ##
    admin_parser = admin.parser(subparsers)
    args = parser.parse_args()
    ##
    # execute tools
    ##
    if 'which' in args:
        if args.which == 'admin':
            admin.execute(args, admin_parser)
        else:
            parser.print_help()
    else:
        parser.print_help()
Esempio n. 2
0
 def __init__(self):
     print("Initializing Sample Class")
     self.O1_IND = 1
     self.O2_IND = 0
     self.NUM_OBJ = 2
     self.O1_COST = 1
     self.O2_COST = 17.6 * self.O1_COST
     self.utils = Utils()
    def __init__(self, index, query, language):
        self.results = list()
        self.query = dict()

        util = Utils(language)
        self.index = index
        self.original_query = util.get_cleaned_tokens(query)

        cleaned_query = Utils.stemmer(self.original_query, language)

        self.add_query_words(cleaned_query)
        self.normalize_frequencies()
Esempio n. 4
0
    def __init__(self, data):
        print("Initializing FlexiBO class")
        self.utils = Utils()
        self.sample = Sample()
        self.df = data
        cfg = ConfigReal()
        (self.E, self.O, self.measurement) = cfg.set_design_space()

        self.NUM_ITER = 200
        self.NUM_OBJ = 2
        self.O1_IND = 0
        self.O2_IND = 1
        self.m1 = "inference_time"
        self.m2 = "power_consumption"
        self.SM = SurrogateModel()
        (self.X, self.Y1, self.Y2) = self.prepare_training_data()
        self.fit_rf()
        self.perform_bo_loop()
Esempio n. 5
0
    def save_index(self):
        util = Utils(self.language)
        processed_files = 0

        if not os.path.isfile('./src/index/index-' + self.language + '.p'):

            for file in [f for f in listdir('./app/corpus/' + self.language) if
                         isfile(join('./app/corpus/' + self.language, f))]:
                if file[0] != '.':
                    text = util.process_file('./app/corpus/' + self.language + '/' + file)
                    if util.load_words_in_index(text, file) is None:
                        self.unprocessed_files.append(file)
                    else:
                        util.set_document_info(text, file)
                        processed_files += 1
                        self.processed_files.append(file)
        else:
            with open('./src/index/index-' + self.language + '.p', 'rb') as input_index:
                index = pickle.load(input_index)
            util.set_index(index)

            for file in self.books_for_index:
                if file[0] != '.' and file not in index.get_documents():
                    text = util.process_file('./app/corpus/' + self.language + '/' + file)
                    if util.load_words_in_index(text, file) is None:
                        self.unprocessed_files.append(file)
                    else:
                        util.set_document_info(text, file)
                        processed_files += 1
                        self.processed_files.append(file)

        if processed_files > 0:
            util.get_index().calculate_weights()
            pickle.dump(util.get_index(), open('./src/index/index-' + self.language + '.p', 'wb'))
            with open('./src/index/index-' + self.language + '.p', 'wb') as output:
                pickle.dump(util.get_index(), output, pickle.HIGHEST_PROTOCOL)
        else:
            exit(1)
Esempio n. 6
0
 def __init__(self, config):
     self.drops_dao = DropsDAO(config)
     self.config = config
     self.utils = Utils()