import re, os from util.model.baseline_classifier import copy_folder from util.d_fill_link_attrs import generate_qslinks, generate_olinks,\ generate_movelinks from util.c_fill_tag_attrs import generate_attributes if __name__ == "__main__": with open('config.txt') as fo: text = fo.read() train_path = re.findall('TRAINING_PATH *= *(.*)', text)[0] gen_path = re.findall('CONFIG_2_GEN_PATH *= *(.*)', text)[0] parent_path = os.path.dirname(gen_path) hyp_a = os.path.join(parent_path, '2a') hyp_b = os.path.join(parent_path, '2b') hyp_c = os.path.join(parent_path, '2c') # 2a copy_folder(gen_path, hyp_a) generate_attributes(train_path, hyp_a, hyp_a) # 2b + c copy_folder(hyp_a, hyp_b) generate_qslinks(train_path, hyp_b, hyp_b) generate_olinks(train_path, hyp_b, hyp_b) generate_movelinks(train_path, hyp_b, hyp_b) copy_folder(hyp_b, hyp_c)
# pre-1a with open('config.txt') as fo: text = fo.read() train_path = re.findall('TRAINING_PATH *= *(.*)', text)[0] gen_path = re.findall('CONFIG_1_GEN_PATH *= *(.*)', text)[0] parent_path = os.path.dirname(gen_path) hyp_1 = os.path.join(parent_path, '1') hyp_a = os.path.join(parent_path, '1a') hyp_b = os.path.join(parent_path, '1b') hyp_c = os.path.join(parent_path, '1c') hyp_d = os.path.join(parent_path, '1d') hyp_e = os.path.join(parent_path, '1e') # 1a + 1b generate_elements(train_path, gen_path, hyp_1) generate_tags(train_path, hyp_1, gen_path, hyp_a) copy_folder(hyp_a, hyp_b) # 1c copy_folder(hyp_b, hyp_c) generate_attributes(train_path, hyp_c, hyp_c) #1d + e copy_folder(hyp_c, hyp_d) generate_qslinks(train_path, hyp_d, hyp_d) generate_olinks(train_path, hyp_d, hyp_d) generate_movelinks(train_path, hyp_d, hyp_d) copy_folder(hyp_d, hyp_e)
'id': '{}{}'.format(type_keys[type_name][0], id_number), } tag.update(type_fields) curr_doc.insert_tag(tag) id_number += 1 # switch to established files curr_doc.save_xml(os.path.join(out_path, doc_name)) clean_corpus = HypotheticalCorpus(out_path) clean_data = list(clean_corpus.documents()) #=============================================================================== if __name__ == "__main__": # DEMO train_path = './data/training' test_path = './data/baseline/test.configuration1/' clean_path = './data/baseline/test.configuration1/' hyp_a = './data/final/test/configuration1/a' hyp_b = './data/final/test/configuration1/b' hyp_c = './data/final/test/configuration1/c' generate_tags(train_path, test_path, clean_path, hyp_a) # copy to next stages copy_folder(hyp_a, hyp_b) copy_folder(hyp_a, hyp_c) d = TypesClassifier('PATH', train_path, test_path, gold_path = '') d.run_demo()
tags = extent.document.query_extents(['SPATIAL_SIGNAL'], extent.lex[0].begin, extent.lex[-1].end) if tags: tag = tags[0] tag.attrs['semantic_type'] = signal_type_labels[offsets] curr_doc.save_xml(os.path.join(out_path, doc_name)) def generate_attributes(train_path, test_path, out_path): # make outpath if not os.path.exists(out_path): os.makedirs(out_path) # attributes for 7 tag types generate_motion_attr(train_path, test_path, out_path) generate_motion_signal_attr(train_path, test_path, out_path) generate_event_attr(train_path, test_path, out_path) generate_path_attr(train_path, test_path, out_path) generate_place_attr(train_path, test_path, out_path) generate_entity_attr(train_path, test_path, out_path) generate_signal_attr(train_path, test_path, out_path) if __name__ == "__main__": # DEMO training_path = './data/training' hyp_c = './data/final/test/configuration1/c' hyp_d = './data/final/test/configuration1/d' generate_attributes(training_path, hyp_c, hyp_c) copy_folder(hyp_c, hyp_d)