def run_model(text): ''' run the model on given text ''' model_path = settings.model_path dictionary_path = settings.dictionary_path pp = Predict(model_path, dictionary_path) results = pp.run(text) return results
def main(argv): # get base & to_diff filenames base_file, diff_file = get_filenames(argv) # get doc-readers for the 2 files... base_doc = DOCReader(base_file) diff_doc = DOCReader(diff_file) # process the sections into hash base_doc_sections_map = {} diff_doc_sections_map = {} for para in base_doc.sections: para = para.strip() k = (para[:11]).strip() base_doc_sections_map[k] = para for para in diff_doc.sections: para = para.strip() k = (para[:11]).strip() diff_doc_sections_map[k] = para # IMP BITs... # for k in base_doc_sections_map.keys(): # # print(base_doc_sections_map[k]) # # print("key:{}; baseSection:{}; diffSection:{}".format(k,base_doc_sections_map[k], diff_doc_sections_map[k])) # logging.debug("key:{}; \nbaseSection:{}; \ndiffSection:{}".format(k,base_doc_sections_map[k], diff_doc_sections_map[k])) # zip 2 files sections zippedClauses = list( zip(base_doc_sections_map.keys(), base_doc_sections_map.values(), diff_doc_sections_map.values())) # call the predictor pred = Predict(zippedClauses) results = pred.run() for res in results: print(res)
# -*- coding: utf-8 -*- from cli import Cli from train import Train from predict import Predict import os import shutil if __name__ == '__main__': if not os.path.isdir('output'): os.mkdir('output') # reset if os.path.isdir('temp'): shutil.rmtree('temp') os.mkdir('temp') # create cli args = Cli.create_parser().parse_args() if args.subparser_name == 'train': t = Train(int(args.model), args.lang) t.run() else: p = Predict(int(args.model)) p.run()