Update fdner.py
Browse files
fdner.py
CHANGED
|
@@ -105,46 +105,4 @@ class fdner(datasets.GeneratorBasedBuilder):
|
|
| 105 |
citation=_CITATION,
|
| 106 |
)
|
| 107 |
|
| 108 |
-
|
| 109 |
-
"""Returns SplitGenerators."""
|
| 110 |
-
downloaded_file = dl_manager.download_and_extract(_URL)
|
| 111 |
-
data_files = {
|
| 112 |
-
"train": os.path.join(downloaded_file, _TRAINING_FILE),
|
| 113 |
-
"dev": os.path.join(downloaded_file, _DEV_FILE),
|
| 114 |
-
"test": os.path.join(downloaded_file, _TEST_FILE),
|
| 115 |
-
}
|
| 116 |
-
|
| 117 |
-
return [
|
| 118 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": data_files["train"]}),
|
| 119 |
-
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": data_files["dev"]}),
|
| 120 |
-
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": data_files["test"]}),
|
| 121 |
-
]
|
| 122 |
-
|
| 123 |
-
def _generate_examples(self, filepath):
|
| 124 |
-
logger.info("⏳ Generating examples from = %s", filepath)
|
| 125 |
-
with open(filepath, encoding="utf-8") as f:
|
| 126 |
-
guid = 0
|
| 127 |
-
tokens = []
|
| 128 |
-
ner_tags = []
|
| 129 |
-
for line in f:
|
| 130 |
-
if line.startswith("-DOCSTART-") or line == "" or line == "\n":
|
| 131 |
-
if tokens:
|
| 132 |
-
yield guid, {
|
| 133 |
-
"id": str(guid),
|
| 134 |
-
"tokens": tokens,
|
| 135 |
-
"ner_tags": ner_tags,
|
| 136 |
-
}
|
| 137 |
-
guid += 1
|
| 138 |
-
tokens = []
|
| 139 |
-
ner_tags = []
|
| 140 |
-
else:
|
| 141 |
-
# conll2003 tokens are space separated
|
| 142 |
-
splits = line.split(" ")
|
| 143 |
-
tokens.append(splits[0])
|
| 144 |
-
ner_tags.append(splits[1].rstrip())
|
| 145 |
-
# last example
|
| 146 |
-
yield guid, {
|
| 147 |
-
"id": str(guid),
|
| 148 |
-
"tokens": tokens,
|
| 149 |
-
"ner_tags": ner_tags,
|
| 150 |
-
}
|
|
|
|
| 105 |
citation=_CITATION,
|
| 106 |
)
|
| 107 |
|
| 108 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|