| 323 | ] |
| 324 | |
| 325 | def get_examples(self, data_dir, split): |
| 326 | path = os.path.join(data_dir, "supervised/{}.txt".format(split)) |
| 327 | with open(path, encoding='utf8') as f: |
| 328 | data = FewNERDProcessor.load_data(f) |
| 329 | |
| 330 | examples = [] |
| 331 | |
| 332 | for idx, (xs, ys, spans) in enumerate(data): |
| 333 | for span in spans: |
| 334 | text_a = " ".join(xs) |
| 335 | meta = { |
| 336 | "entity": " ".join(xs[span[0]: span[1]+1]) |
| 337 | } |
| 338 | example = InputExample(guid=str(idx), text_a=text_a, meta=meta, label=self.get_label_id(ys[span[0]][2:])) |
| 339 | examples.append(example) |
| 340 | |
| 341 | return examples |
| 342 | |
| 343 | @staticmethod |
| 344 | def load_data(file): |