Datasets:
Tasks:
Token Classification
Sub-tasks:
named-entity-recognition
Languages:
English
Size:
1K<n<10K
License:
Update indian_names.py
Browse files1 unmodified line234567814 unmodified lines23242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001 unmodified linelogger = datasets.logging.get_logger(__name__)_URL = "https://raw.githubusercontent.com/Kriyansparsana/demorepo/main/wnut17train%20(1).conll"class indian_namesConfig(datasets.BuilderConfig):"""The WNUT 17 Emerging Entities Dataset."""14 unmodified lines),]def _info(self):return datasets.DatasetInfo(features=datasets.Features({"id": datasets.Value("string"),"tokens": datasets.Sequence(datasets.Value("string")),"ner_tags": datasets.Sequence(datasets.features.ClassLabel(names=["O","B-corporation","I-corporation","B-person","I-person"])),}),supervised_keys=None,)def _split_generators(self, dl_manager):"""Returns SplitGenerators."""urls_to_download = {"train": f"{_URL}",}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 = []sentence_counter = 0for row in f:row = row.rstrip()if row:if "\t" in row:token, label = row.split("\t")current_tokens.append(token)current_labels.append(label)else:# Handle cases where the delimiter is missing# You can choose to skip these rows or handle them differentlylogger.warning(f"Delimiter missing in row: {row}")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,{"id": str(sentence_counter),"tokens": current_tokens,"ner_tags": current_labels,},)sentence_counter += 1current_tokens = []current_labels = []yield sentence# Don't forget the last sentence in the dataset 🧐if current_tokens:yield sentence_counter, {"id": str(sentence_counter),"tokens": current_tokens,"ner_tags": current_labels,}1 unmodified line234567814 unmodified lines23242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901 unmodified linelogger = datasets.logging.get_logger(__name__)_URL = "https://raw.githubusercontent.com/Kriyansparsana/demorepo/main/train.txt"class indian_namesConfig(datasets.BuilderConfig):"""The WNUT 17 Emerging Entities Dataset."""14 unmodified lines),]def _info(self):return datasets.DatasetInfo(description=_DESCRIPTION,features=datasets.Features({"id": datasets.Value("string"),"tokens": datasets.Sequence(datasets.Value("string")),"pos_tags": datasets.Sequence(datasets.features.ClassLabel(names=['"',"''","#","$","(",")",",",".",":","``","CC","CD","DT","EX","FW","IN","JJ","JJR","JJS","LS","MD","NN","NNP","NNPS","NNS","NN|SYM","PDT","POS","PRP","PRP$","RB","RBR","RBS","RP","SYM","TO","UH","VB","VBD","VBG","VBN","VBP","VBZ","WDT","WP","WP$","WRB",])),"chunk_tags": datasets.Sequence(datasets.features.ClassLabel(names=["O","B-ADJP","I-ADJP","B-ADVP","I-ADVP","B-CONJP","I-CONJP","B-INTJ","I-INTJ","B-LST","I-LST","B-NP","I-NP","B-PP","I-PP","B-PRT","I-PRT","B-SBAR","I-SBAR","B-UCP","I-UCP","B-VP","I-VP",])),"ner_tags": datasets.Sequence(datasets.features.ClassLabel(names=["O","B-PER","I-PER","B-ORG","I-ORG","B-LOC","I-LOC","B-MISC","I-MISC",])),}),supervised_keys=None,homepage="https://www.aclweb.org/anthology/W03-0419/",citation=_CITATION,)def _split_generators(self, dl_manager):"""Returns SplitGenerators."""downloaded_file = dl_manager.download_and_extract(_URL)data_files = {"train": os.path.join(downloaded_file, _TRAINING_FILE),"dev": os.path.join(downloaded_file, _DEV_FILE),"test": os.path.join(downloaded_file, _TEST_FILE),}return [datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": data_files["train"]}),datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": data_files["dev"]}),datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": data_files["test"]}),]def _generate_examples(self, filepath):logger.info("⏳ Generating examples from = %s", filepath)with open(filepath, encoding="utf-8") as f:guid = 0tokens = []pos_tags = []chunk_tags = []ner_tags = []for line in f:if line.startswith("-DOCSTART-") or line == "" or line == "\n":if tokens:yield guid, {"id": str(guid),"tokens": tokens,"pos_tags": pos_tags,"chunk_tags": chunk_tags,"ner_tags": ner_tags,}guid += 1tokens = []pos_tags = []chunk_tags = []ner_tags = []else:# conll2003 tokens are space separatedsplits = line.split(" ")tokens.append(splits[0])pos_tags.append(splits[1])chunk_tags.append(splits[2])ner_tags.append(splits[3].rstrip())# last exampleif tokens:yield guid, {"id": str(guid),"tokens": tokens,"pos_tags": pos_tags,"chunk_tags": chunk_tags,"ner_tags": ner_tags,}
indian_names.py+138-48