def main(conf): basic_para = Basic(config=conf) if not basic_para.cmd_log and basic_para.log_dir: mode = "" if basic_para.do_training: mode += "_train" if basic_para.do_test: mode += "_test" log_path = os.path.join( basic_para.log_dir, basic_para.model_name, basic_para.run_name + mode + ".log", ) append_num_to_path(log_path) ensure_dir(log_path) set_file_log(log_path) print("Logging is set at: " + log_path) if basic_para.debug_mode: set_basic_log(logging.DEBUG) else: set_basic_log() logger.info("Started the runner at " + strftime("%Y-%m-%d_%H-%M-%S", localtime())) logger.info(json.dumps(conf, indent=2)) runner = ArgRunner(config=conf) if basic_para.run_baselines: runner.run_baselines(basic_para) if basic_para.do_training: runner.train(basic_para, resume=True) if basic_para.do_test: if not basic_para.test_in: logger.error("Test data path is not provided.") if not os.path.exists(basic_para.test_in): logger.error(f"Cannot find test path at {basic_para.test_in}") result_dir = os.path.join( basic_para.log_dir, basic_para.model_name, basic_para.run_name, basic_para.test_data, ) logger.info("Evaluation results will be saved in: " + result_dir) runner.test( test_in=basic_para.test_in, eval_dir=result_dir, )
help="Which frame formalism is to predict the slots, currently support " "FrameNet and Propbank", default_value="Propbank", ).tag(config=True) use_gold_frame = Bool( help="Use gold the gold frame produced by annotation", default_value=False).tag(config=True) strict_arg_count = Bool(help="Force lossless number of arguments", default_value=False).tag(config=True) if __name__ == "__main__": from event.util import load_mixed_configs, set_basic_log set_basic_log() hash_params = HashParam(config=load_mixed_configs()) stat_counters = { "predicate": Counter(), "implicit predicates": Counter(), "implicit slots": Counter(), } stat_keys = stat_counters.keys() hash_data() print("==========Implicit arguments Statistics===========") headline = "Predicate\t" + "\t".join(stat_keys) print(headline) preds = sorted(stat_counters["implicit predicates"].keys())
tag_vocab, config.language) dev_reader = ConllUReader(config.dev_files, config, token_vocab, train_reader.tag_vocab, config.language) detector = DetectionTrainer(config, token_vocab, tag_vocab) detector.train(train_reader, dev_reader) # def __init__(self, component_name, run_id, out_path): res_collector = CSR("Event_hector_frames", 1, config.output, "belcat") test_reader = ConllUReader(config.test_files, config, token_vocab, train_reader.tag_vocab) detector.predict(test_reader, res_collector) res_collector.run() if __name__ == "__main__": from event import util parser = util.evm_args() arguments = parser.parse_args() util.set_basic_log() logging.info("Starting with the following config:") logging.info(arguments) main(arguments)