def baseline_predict(instances): predictions = [] with open(Config.raw_test_set(), "w") as fp: for instance in instances: fp.write("%s\n" % json.dumps(instance)) pipeline.main() with open(Config.submission_file(), "r") as fp: for line in fp: predictions.append(json.loads(line.strip())) return predictions
def main(args=NullArgs()): LogHelper.setup() logger = LogHelper.get_logger( os.path.splitext(os.path.basename(__file__))[0]) args.mode = Mode.PREDICT if args.config is not None: Config.load_config(args.config) if args.out_file is not None: Config.relative_path_submission = args.out_file if args.in_file is not None: Config.relative_path_test_file = args.in_file if args.database is not None: Config.relative_path_db = args.database print("relative_path_db " + Config.relative_path_db) print("raw_test_set " + Config.raw_test_set()) if os.path.exists(Config.test_doc_file): os.remove(Config.test_doc_file) if os.path.exists(Config.test_set_file): os.remove(Config.test_set_file) if args.mode in {Mode.PIPELINE, Mode.PREDICT, Mode.PREDICT_ALL_DATASETS}: logger.info( "=========================== Sub-task 1. Document Retrieval ==========================================" ) document_retrieval(logger, args.mode) if args.mode in { Mode.PIPELINE_NO_DOC_RETR, Mode.PIPELINE, Mode.PREDICT, Mode.PREDICT_NO_DOC_RETR, Mode.PREDICT_ALL_DATASETS, Mode.PREDICT_NO_DOC_RETR_ALL_DATASETS }: logger.info( "=========================== Sub-task 2. Sentence Retrieval ==========================================" ) sentence_retrieval_ensemble(logger, args.mode) logger.info( "=========================== Sub-task 3. Claim Validation ============================================" ) rte(logger, args, args.mode)