def run_script(self, cmd): # print("RUN", cmd) with tempfile.TemporaryDirectory() as tmpdir: outfile = pathlib.Path(tmpdir) / "out.trees" # Avoid dairquiri mucking up the logging setup for unittest. with unittest.mock.patch("daiquiri.setup"): algorithms.main(cmd.split() + [str(outfile)]) return tskit.load(outfile)
def run(args): l = loader.DataLoader(args.dataset, args.k, args.mode, args.dataset_path, args.crowd_annotations_path, args.ground_truths_path) data, gt = l.get_data() result, accuracy = algorithms.main(args, data, gt) ind_to_question_dict = l.get_ind_to_question_dict() ind_to_annotation_dict = l.get_ind_to_annotation_dict() result_annotations = pd.DataFrame(data=result, columns=['Annotation']) result_annotations.reset_index(level=0, inplace=True) result_annotations = result_annotations.rename( columns={'index': 'Question'}) result_annotations['Question'] = result_annotations['Question'].map( ind_to_question_dict) result_annotations['Annotation'] = result_annotations['Annotation'].map( ind_to_annotation_dict) if args.print_result: print("Predictions:") print(result_annotations) if args.mode == 'test': print("Accuracy:") print(accuracy) if args.output is not None: utils.to_csv(result, args.output, ind_to_question_dict, ind_to_annotation_dict)
def main(events): # Main function try: for event in events.listen(): if event.type == VkBotEventType.MESSAGE_NEW: # For messages in chat response = event.message.text.lower() keyboard = Keyboard(response).create_main() if int(event.message.peer_id) != 233071173: response = algorithms.main(response, data.commands) Messages().response_determination(admin=False, response=response, event=event, keyboard=keyboard) else: Messages().response_determination(admin=True, response=response, event=event, keyboard=keyboard) if event.message.payload is not None: Messages.payload_determination(event) time.sleep(1) except: time.sleep(1) return main(longpoll)
import algorithms if __name__ == "__main__": algorithms.main()