Update inspec_ke_tagged.py
Browse files- inspec_ke_tagged.py +29 -0
inspec_ke_tagged.py
CHANGED
@@ -90,3 +90,32 @@ class InspecKETagged(datasets.GeneratorBasedBuilder):
|
|
90 |
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
|
91 |
]
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
90 |
datasets.SplitGenerator(name=datasets.Split.TEST, gen_kwargs={"filepath": downloaded_files["test"]}),
|
91 |
]
|
92 |
|
93 |
+
def _generate_examples(self, filepath):
|
94 |
+
logger.info("⏳ Generating examples from = %s", filepath)
|
95 |
+
with open(filepath, encoding="utf-8") as f:
|
96 |
+
guid = 0
|
97 |
+
tokens = []
|
98 |
+
ke_tags = []
|
99 |
+
for line in f:
|
100 |
+
if line == "" or line == "\n":
|
101 |
+
if tokens:
|
102 |
+
yield guid, {
|
103 |
+
"id": str(guid),
|
104 |
+
"tokens": tokens,
|
105 |
+
"ke_tags": ke_tags,
|
106 |
+
}
|
107 |
+
guid += 1
|
108 |
+
tokens = []
|
109 |
+
ke_tags = []
|
110 |
+
else:
|
111 |
+
# the tokens are space separated
|
112 |
+
splits = line.split()
|
113 |
+
print(splits)
|
114 |
+
tokens.append(splits[0])
|
115 |
+
ke_tags.append(splits[1].rstrip())
|
116 |
+
# last example
|
117 |
+
yield guid, {
|
118 |
+
"id": str(guid),
|
119 |
+
"tokens": tokens,
|
120 |
+
"ke_tags": ke_tags,
|
121 |
+
}
|