Datasets:
Tasks:
Token Classification
Modalities:
Text
Formats:
csv
Sub-tasks:
named-entity-recognition
Languages:
English
Size:
1K - 10K
License:
| import datasets | |
| class NERDataset(datasets.GeneratorBasedBuilder): | |
| VERSION = datasets.Version("1.0.0") | |
| def _info(self): | |
| return datasets.DatasetInfo( | |
| description="A NER dataset for named entity recognition tasks.", | |
| features=datasets.Features( | |
| { | |
| "text": datasets.Value("string"), | |
| "label": datasets.Value("string"), | |
| } | |
| ), | |
| homepage="https://huggingface.co/datasets/tanaos/synthetic-NER-dataset-v1", | |
| license="mit", | |
| ) | |
| def _split_generators(self, dl_manager): | |
| # The dataset only has one file | |
| data_path = self.config.data_dir or "./data/data.csv" | |
| return [ | |
| datasets.SplitGenerator( | |
| name=datasets.Split.TRAIN, | |
| gen_kwargs={"filepath": data_path}, | |
| ), | |
| ] | |
| def _generate_examples(self, filepath): | |
| """ | |
| Yields examples as (key, example) tuples. | |
| """ | |
| import csv | |
| with open(filepath, encoding="utf-8") as f: | |
| reader = csv.DictReader(f) | |
| for i, row in enumerate(reader): | |
| yield i, { | |
| "text": row["text"], | |
| "label": int(row["label"]), | |
| } | |