Creates a task w/ correct filenames and postprocessing.
(task, context, delimiter_type,
evidence_marker_type)
| 106 | |
| 107 | |
| 108 | def create_task(task, context, delimiter_type, |
| 109 | evidence_marker_type): |
| 110 | """Creates a task w/ correct filenames and postprocessing.""" |
| 111 | |
| 112 | # Fill in template fields that are common across train/dev/test. |
| 113 | task_basename = "_".join([ |
| 114 | "wikidiff", |
| 115 | task.name, |
| 116 | context, |
| 117 | delimiter_type.name, |
| 118 | evidence_marker_type.name, |
| 119 | ]) |
| 120 | filepath = functools.partial( |
| 121 | FILEPATH_TEMPLATE.format, |
| 122 | task=task.name, |
| 123 | delimiter_type=delimiter_type.name, |
| 124 | evidence_marker_type=evidence_marker_type.name, |
| 125 | ) |
| 126 | register = functools.partial( |
| 127 | _register_w_defaults, |
| 128 | task=task, |
| 129 | delimiter_type=delimiter_type, |
| 130 | ) |
| 131 | |
| 132 | # Create train task |
| 133 | train_prefix = filepath(split="train", context=context) |
| 134 | train_fnames = [f"{train_prefix}-0000{i}-of-00010" for i in range(9)] |
| 135 | validation_fname = f"{train_prefix}-00009-of-00010" |
| 136 | split_to_filepattern = {"train": train_fnames, "validation": validation_fname} |
| 137 | register(task_basename, split_to_filepattern) |
| 138 | |
| 139 | # Create train (old) task |
| 140 | train_old_prefix = filepath(split="train_old", context=context) |
| 141 | train_old_fnames = [f"{train_old_prefix}-0000{i}-of-00010" for i in range(9)] |
| 142 | validation_old_fname = f"{train_old_prefix}-00009-of-00010" |
| 143 | split_to_filepattern = { |
| 144 | "train": train_old_fnames, |
| 145 | "validation": validation_old_fname |
| 146 | } |
| 147 | register(f"{task_basename}_old", split_to_filepattern) |
| 148 | |
| 149 | # Create (all evidence) evaluation tasks. |
| 150 | dev_prefix = filepath(split="dev", context="all") |
| 151 | dev_split_to_filepattern = {"test": f"{dev_prefix}-*"} |
| 152 | register(f"{task_basename}_dev", dev_split_to_filepattern) |
| 153 | |
| 154 | test_prefix = filepath(split="test", context="all") |
| 155 | test_split_to_filepattern = {"test": f"{test_prefix}-*"} |
| 156 | register(f"{task_basename}_test", test_split_to_filepattern) |
| 157 | |
| 158 | # Create (oracle evidence) evaluation tasks. |
| 159 | oracle_dev_prefix = filepath(split="dev", context="gold") |
| 160 | oracle_dev_split_to_file_pattern = {"test": f"{oracle_dev_prefix}-*"} |
| 161 | register(f"{task_basename}_oracle_dev", oracle_dev_split_to_file_pattern) |
| 162 | |
| 163 | oracle_test_prefix = filepath(split="test", context="gold") |
| 164 | oracle_test_split_to_file_pattern = {"test": f"{oracle_test_prefix}-*"} |
| 165 | register(f"{task_basename}_oracle_test", oracle_test_split_to_file_pattern) |
no outgoing calls
no test coverage detected
searching dependent graphs…