Datasets:
Tasks:
Token Classification
Sub-tasks:
named-entity-recognition
Languages:
English
Size:
1K<n<10K
License:
Update indian_names.py
Browse files- indian_names.py +3 -7
indian_names.py
CHANGED
@@ -56,8 +56,7 @@ class indina_names(datasets.GeneratorBasedBuilder):
|
|
56 |
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
57 |
]
|
58 |
|
59 |
-
|
60 |
-
logger.info("⏳ Generating examples from = %s", filepath)
|
61 |
with open(filepath, encoding="utf-8") as f:
|
62 |
current_tokens = []
|
63 |
current_labels = []
|
@@ -65,15 +64,13 @@ class indina_names(datasets.GeneratorBasedBuilder):
|
|
65 |
for row in f:
|
66 |
row = row.rstrip()
|
67 |
if row:
|
68 |
-
token, label = row.split("
|
69 |
current_tokens.append(token)
|
70 |
current_labels.append(label)
|
71 |
else:
|
72 |
-
# New sentence
|
73 |
if not current_tokens:
|
74 |
-
# Consecutive empty lines will cause empty sentences
|
75 |
continue
|
76 |
-
assert len(current_tokens) == len(current_labels), "
|
77 |
sentence = (
|
78 |
sentence_counter,
|
79 |
{
|
@@ -86,7 +83,6 @@ class indina_names(datasets.GeneratorBasedBuilder):
|
|
86 |
current_tokens = []
|
87 |
current_labels = []
|
88 |
yield sentence
|
89 |
-
# Don't forget last sentence in dataset 🧐
|
90 |
if current_tokens:
|
91 |
yield sentence_counter, {
|
92 |
"id": str(sentence_counter),
|
|
|
56 |
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_files["train"]}),
|
57 |
]
|
58 |
|
59 |
+
def _generate_examples(self, filepath):
|
|
|
60 |
with open(filepath, encoding="utf-8") as f:
|
61 |
current_tokens = []
|
62 |
current_labels = []
|
|
|
64 |
for row in f:
|
65 |
row = row.rstrip()
|
66 |
if row:
|
67 |
+
token, label = row.split(",")
|
68 |
current_tokens.append(token)
|
69 |
current_labels.append(label)
|
70 |
else:
|
|
|
71 |
if not current_tokens:
|
|
|
72 |
continue
|
73 |
+
assert len(current_tokens) == len(current_labels), "Mismatch between tokens and labels"
|
74 |
sentence = (
|
75 |
sentence_counter,
|
76 |
{
|
|
|
83 |
current_tokens = []
|
84 |
current_labels = []
|
85 |
yield sentence
|
|
|
86 |
if current_tokens:
|
87 |
yield sentence_counter, {
|
88 |
"id": str(sentence_counter),
|