Commit ·
566322f
1
Parent(s): 9aaff4f
Update ubb-endava-assistant-ner-only-misc.py
Browse files
ubb-endava-assistant-ner-only-misc.py
CHANGED
|
@@ -34,22 +34,22 @@ _DEV_FILE = "validation.txt"
|
|
| 34 |
_TEST_FILE = "test.txt"
|
| 35 |
|
| 36 |
|
| 37 |
-
class
|
| 38 |
-
"""BuilderConfig for
|
| 39 |
|
| 40 |
def __init__(self, **kwargs):
|
| 41 |
-
"""BuilderConfig for
|
| 42 |
Args:
|
| 43 |
**kwargs: keyword arguments forwarded to super.
|
| 44 |
"""
|
| 45 |
-
super(
|
| 46 |
|
| 47 |
|
| 48 |
-
class
|
| 49 |
-
"""
|
| 50 |
|
| 51 |
BUILDER_CONFIGS = [
|
| 52 |
-
|
| 53 |
]
|
| 54 |
|
| 55 |
def _info(self):
|
|
@@ -84,21 +84,23 @@ class UBBEndavaNER(datasets.GeneratorBasedBuilder):
|
|
| 84 |
|
| 85 |
def _split_generators(self, dl_manager):
|
| 86 |
"""Returns SplitGenerators."""
|
| 87 |
-
|
| 88 |
-
path = "
|
| 89 |
data_files = {
|
| 90 |
"train": os.path.join(path, _TRAINING_FILE),
|
| 91 |
"validation": os.path.join(path, _DEV_FILE),
|
| 92 |
"test": os.path.join(path, _TEST_FILE),
|
| 93 |
}
|
| 94 |
|
|
|
|
| 95 |
return [
|
| 96 |
-
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath":
|
| 97 |
-
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath":
|
| 98 |
-
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath":
|
| 99 |
]
|
| 100 |
|
| 101 |
def _generate_examples(self, filepath):
|
|
|
|
| 102 |
logger.info("⏳ Generating examples from = %s", filepath)
|
| 103 |
with open(filepath, encoding="utf-8") as f:
|
| 104 |
guid = 0
|
|
@@ -116,7 +118,7 @@ class UBBEndavaNER(datasets.GeneratorBasedBuilder):
|
|
| 116 |
tokens = []
|
| 117 |
ner_tags = []
|
| 118 |
else:
|
| 119 |
-
#
|
| 120 |
splits = line.split(" ")
|
| 121 |
tokens.append(splits[0])
|
| 122 |
ner_tags.append(splits[3].rstrip())
|
|
|
|
| 34 |
_TEST_FILE = "test.txt"
|
| 35 |
|
| 36 |
|
| 37 |
+
class UBBDemoConfig(datasets.BuilderConfig):
|
| 38 |
+
"""BuilderConfig for UBBDemo"""
|
| 39 |
|
| 40 |
def __init__(self, **kwargs):
|
| 41 |
+
"""BuilderConfig for UBBDemo.
|
| 42 |
Args:
|
| 43 |
**kwargs: keyword arguments forwarded to super.
|
| 44 |
"""
|
| 45 |
+
super(UBBDemoConfig, self).__init__(**kwargs)
|
| 46 |
|
| 47 |
|
| 48 |
+
class UBBDemo(datasets.GeneratorBasedBuilder):
|
| 49 |
+
"""UBBDemo dataset."""
|
| 50 |
|
| 51 |
BUILDER_CONFIGS = [
|
| 52 |
+
UBBDemoConfig(name="UBBDemo", version=datasets.Version("1.0.0"), description="UBBDemo dataset"),
|
| 53 |
]
|
| 54 |
|
| 55 |
def _info(self):
|
|
|
|
| 84 |
|
| 85 |
def _split_generators(self, dl_manager):
|
| 86 |
"""Returns SplitGenerators."""
|
| 87 |
+
|
| 88 |
+
path = "./"
|
| 89 |
data_files = {
|
| 90 |
"train": os.path.join(path, _TRAINING_FILE),
|
| 91 |
"validation": os.path.join(path, _DEV_FILE),
|
| 92 |
"test": os.path.join(path, _TEST_FILE),
|
| 93 |
}
|
| 94 |
|
| 95 |
+
downloaded_file = dl_manager.download_and_extract(data_files)
|
| 96 |
return [
|
| 97 |
+
datasets.SplitGenerator(name=datasets.Split.TRAIN, gen_kwargs={"filepath": downloaded_file ["train"]}),
|
| 98 |
+
datasets.SplitGenerator(name=datasets.Split.VALIDATION, gen_kwargs={"filepath": downloaded_file ["validation"]}),
|
| 99 |
+
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_file ["test"]}),
|
| 100 |
]
|
| 101 |
|
| 102 |
def _generate_examples(self, filepath):
|
| 103 |
+
print("I am here" + filepath)
|
| 104 |
logger.info("⏳ Generating examples from = %s", filepath)
|
| 105 |
with open(filepath, encoding="utf-8") as f:
|
| 106 |
guid = 0
|
|
|
|
| 118 |
tokens = []
|
| 119 |
ner_tags = []
|
| 120 |
else:
|
| 121 |
+
# UBBDemo tokens are space separated
|
| 122 |
splits = line.split(" ")
|
| 123 |
tokens.append(splits[0])
|
| 124 |
ner_tags.append(splits[3].rstrip())
|