Datasets:
Tasks:
Token Classification
Sub-tasks:
named-entity-recognition
Languages:
English
Size:
1K<n<10K
License:
Update indian_names.py
Browse files5 unmodified lines678910111213141516171819202122232425262 unmodified lines2930313233343536373839404142434445464748495051525354551 unmodified line575859606162636465666768696 unmodified lines7677787980815 unmodified lines_TRAINING_FILE = "indian-name-org.csv"class indian_namesConfig(datasets.BuilderConfig):def __init__(self, **kwargs):super(indian_namesConfig, self).__init__(**kwargs)class indian_names(datasets.GeneratorBasedBuilder):BUILDER_CONFIGS = [indian_namesConfig(name="indian_names_dataset",version=datasets.Version("1.0.0"),description="Indian Names Dataset",),]def _info(self):return datasets.DatasetInfo(description="Indian Names dataset",features=datasets.Features({"id": datasets.Value("string"),2 unmodified linesdatasets.features.ClassLabel(names=["B-PER","I-ORG",])),}),)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"]}),]def _generate_examples(self, filepath):with open(filepath, encoding="utf-8") as f:current_tokens = []current_labels = []1 unmodified linefor row in f:row = row.rstrip()if row:token, label = row.split(",")current_tokens.append(token)current_labels.append(label)else:if not current_tokens:continueassert len(current_tokens) == len(current_labels), "Mismatch between tokens and labels"sentence = (sentence_counter,{6 unmodified linescurrent_tokens = []current_labels = []yield sentenceif current_tokens:yield sentence_counter, {"id": str(sentence_counter),5 unmodified lines67891011121314151617181920212223242526272829303132332 unmodified lines363738394041424344454647484950515253545556575859606162631 unmodified line6566676869707172737475767778796 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(WNUT_17Config, self).__init__(**kwargs)class indina_names(datasets.GeneratorBasedBuilder):"""The WNUT 17 Emerging Entities Dataset."""BUILDER_CONFIGS = [indian_namesConfig(name="wnut_17", version=datasets.Version("1.0.0"), description="The WNUT 17 Emerging Entities Dataset"),]def _info(self):return datasets.DatasetInfo(description=_DESCRIPTION,features=datasets.Features({"id": datasets.Value("string"),2 unmodified linesdatasets.features.ClassLabel(names=["B-PER","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)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 linefor row in f:row = row.rstrip()if row:token, label = row.split("\t")current_tokens.append(token)current_labels.append(label)else:# New sentenceif not current_tokens:# Consecutive empty lines will cause empty sentencescontinueassert len(current_tokens) == len(current_labels), "💔 between len of tokens & labels"sentence = (sentence_counter,{6 unmodified linescurrent_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