| import json |
| import datasets |
|
|
| class GeoWikiFeatures(datasets.GeneratorBasedBuilder): |
| VERSION = datasets.Version("1.0.0") |
|
|
| def _info(self): |
| return datasets.DatasetInfo( |
| features=datasets.Features({ |
| "sentence": datasets.Value("string"), |
| "annotations": datasets.Sequence({ |
| "text": datasets.Value("string"), |
| "label": datasets.Value("string"), |
| "start": datasets.Value("int32"), |
| "end": datasets.Value("int32"), |
| }), |
| }) |
| ) |
|
|
| def _split_generators(self, dl_manager): |
| return [ |
| datasets.SplitGenerator( |
| name=datasets.Split.TRAIN, |
| gen_kwargs={"filepath": "train.jsonl"}, |
| ), |
| datasets.SplitGenerator( |
| name=datasets.Split.VALIDATION, |
| gen_kwargs={"filepath": "validation.jsonl"}, |
| ), |
| datasets.SplitGenerator( |
| name=datasets.Split.TEST, |
| gen_kwargs={"filepath": "test.jsonl"}, |
| ), |
| ] |
|
|
| def _generate_examples(self, filepath): |
| with open(filepath, encoding="utf-8") as f: |
| for i, line in enumerate(f): |
| yield i, json.loads(line) |
|
|
|
|