Datasets:
Tasks:
Token Classification
Sub-tasks:
named-entity-recognition
Languages:
English
Size:
1K<n<10K
License:
Update indian_names.py
Browse files5 unmodified lines67891011121314151016171819202112222315161724252627282923303132332 unmodified lines3637383239404142434445464748495051525354414243444546474849555657505859606162631 unmodified line65666760686970717273747566767778796 unmodified lines868788899091925 unmodified lines_TRAINING_FILE = "indian-name-org.csv"
class indian_namesConfig(datasets.BuilderConfig): """The WNUT 17 Emerging Entities Dataset."""
def __init__(self, **kwargs): """BuilderConfig for WNUT 17. Args: **kwargs: keyword arguments forwarded to super. """ super(indian_namesConfig, self).__init__(**kwargs) super(WNUT_17Config, self).__init__(**kwargs)
class indina_names(datasets.GeneratorBasedBuilder): """The WNUT 17 Emerging Entities Dataset."""
class indian_names(datasets.GeneratorBasedBuilder): BUILDER_CONFIGS = [ indian_namesConfig( name="indian_names_dataset", version=datasets.Version("1.0.0"), description="Indian Names Dataset", name="wnut_17", version=datasets.Version("1.0.0"), description="The WNUT 17 Emerging Entities Dataset" ), ]
def _info(self): return datasets.DatasetInfo( description="Indian Names dataset", description=_DESCRIPTION, features=datasets.Features( { "id": datasets.Value("string"),2 unmodified lines datasets.features.ClassLabel( names=[ "B-PER", "I-ORG", "B-ORG", ] ) ), } ), supervised_keys=None, )
def _split_generators(self, dl_manager): """Returns SplitGenerators.""" urls_to_download = { "train": f"{_URL}{_TRAINING_FILE}", } downloaded_files = dl_manager.download_and_extract(urls_to_download)
def _split_generators(self, dl_manager): urls_to_download = { "train": f"{_URL}{_TRAINING_FILE}", } downloaded_files = dl_manager.download_and_extract(urls_to_download)
return [ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}), ] return [ datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}), ]
def _generate_examples(self, filepath): logger.info("⏳ Generating examples from = %s", filepath) with open(filepath, encoding="utf-8") as f: current_tokens = [] current_labels = []1 unmodified line for row in f: row = row.rstrip() if row: token, label = row.split(",") token, label = row.split("\t") current_tokens.append(token) current_labels.append(label) else: # New sentence if not current_tokens: # Consecutive empty lines will cause empty sentences continue assert len(current_tokens) == len(current_labels), "Mismatch between tokens and labels" assert len(current_tokens) == len(current_labels), "💔 between len of tokens & labels" sentence = ( sentence_counter, {6 unmodified lines current_tokens = [] current_labels = [] yield sentence # Don't forget last sentence in dataset 🧐 if current_tokens: yield sentence_counter, { "id": str(sentence_counter),indian_names.py+30-19