(samples)
| 218 | |
| 219 | def get_data_split(data_dir, split_file, candidate_results=None, cache_dir=None, is_train=False, is_debug=False): |
| 220 | def flatten_actions(samples): |
| 221 | outputs = { |
| 222 | "website": [], |
| 223 | "confirmed_task": [], |
| 224 | "annotation_id": [], |
| 225 | "previous_actions": [], |
| 226 | "action_uid": [], |
| 227 | "operation": [], |
| 228 | "pos_candidates": [], |
| 229 | "neg_candidates": [], |
| 230 | "cleaned_html": [], |
| 231 | } |
| 232 | num_actions = [len(actions) for actions in samples["actions"]] |
| 233 | for key in ["website", "confirmed_task", "annotation_id"]: |
| 234 | for idx, value in enumerate(samples[key]): |
| 235 | outputs[key] += [value] * num_actions[idx] |
| 236 | for actions, action_reprs in zip(samples["actions"], samples["action_reprs"]): |
| 237 | for a_idx, action in enumerate(actions): |
| 238 | outputs["previous_actions"].append(action_reprs[:a_idx]) |
| 239 | for key in [ |
| 240 | "action_uid", |
| 241 | "operation", |
| 242 | "pos_candidates", |
| 243 | "neg_candidates", |
| 244 | "cleaned_html", |
| 245 | ]: |
| 246 | outputs[key].append(action[key]) |
| 247 | return outputs |
| 248 | dataset = load_dataset(data_dir, data_files=split_file, split="all", cache_dir=cache_dir) |
| 249 | if is_debug: |
| 250 | dataset = dataset.select(range(3)) |
nothing calls this directly
no outgoing calls
no test coverage detected