Datasets:
Tasks:
Text Classification
Sub-tasks:
multi-class-classification
Languages:
English
Multilinguality:
monolingual
Size Categories:
10K<n<100K
Language Creators:
found
Annotations Creators:
other
Source Datasets:
extended|other
ArXiv:
License:
renamed subj/obj to e1/e2 to better align with dataset
Browse files
kbp37.py
CHANGED
@@ -123,10 +123,10 @@ class KBP37(datasets.GeneratorBasedBuilder):
|
|
123 |
{
|
124 |
"id": datasets.Value("string"),
|
125 |
"token": datasets.Sequence(datasets.Value("string")),
|
126 |
-
"
|
127 |
-
"
|
128 |
-
"
|
129 |
-
"
|
130 |
"relation": datasets.ClassLabel(names=_CLASS_LABELS),
|
131 |
}
|
132 |
)
|
@@ -198,35 +198,36 @@ class KBP37(datasets.GeneratorBasedBuilder):
|
|
198 |
text = text.replace("</e2>", " </e2> ")
|
199 |
text = text.strip().replace(r"\s\s+", r"\s")
|
200 |
tokens = text.split()
|
201 |
-
|
202 |
-
|
203 |
-
if
|
204 |
-
tokens.pop(
|
205 |
-
|
206 |
-
tokens.pop(
|
207 |
-
|
208 |
-
tokens.pop(
|
209 |
-
|
210 |
-
tokens.pop(
|
211 |
else:
|
212 |
-
|
213 |
-
|
214 |
-
tokens.
|
215 |
-
|
216 |
-
tokens.
|
217 |
-
|
218 |
-
tokens.
|
|
|
219 |
|
220 |
# some examples, like train/1276 are invalid (empty head/tail), and
|
221 |
# yield non-sensical examples without this check
|
222 |
-
if
|
223 |
yield int(id_), {
|
224 |
"id": id_,
|
225 |
"token": tokens,
|
226 |
-
"
|
227 |
-
"
|
228 |
-
"
|
229 |
-
"
|
230 |
"relation": relation,
|
231 |
}
|
232 |
else:
|
|
|
123 |
{
|
124 |
"id": datasets.Value("string"),
|
125 |
"token": datasets.Sequence(datasets.Value("string")),
|
126 |
+
"e1_start": datasets.Value("int32"),
|
127 |
+
"e1_end": datasets.Value("int32"),
|
128 |
+
"e2_start": datasets.Value("int32"),
|
129 |
+
"e2_end": datasets.Value("int32"),
|
130 |
"relation": datasets.ClassLabel(names=_CLASS_LABELS),
|
131 |
}
|
132 |
)
|
|
|
198 |
text = text.replace("</e2>", " </e2> ")
|
199 |
text = text.strip().replace(r"\s\s+", r"\s")
|
200 |
tokens = text.split()
|
201 |
+
e1_start = tokens.index("<e1>")
|
202 |
+
e2_start = tokens.index("<e2>")
|
203 |
+
if e1_start < e2_start:
|
204 |
+
tokens.pop(e1_start)
|
205 |
+
e1_end = tokens.index("</e1>")
|
206 |
+
tokens.pop(e1_end)
|
207 |
+
e2_start = tokens.index("<e2>")
|
208 |
+
tokens.pop(e2_start)
|
209 |
+
e2_end = tokens.index("</e2>")
|
210 |
+
tokens.pop(e2_end)
|
211 |
else:
|
212 |
+
print('Should not happen: ' + example)
|
213 |
+
tokens.pop(e2_start)
|
214 |
+
e2_end = tokens.index("</e2>")
|
215 |
+
tokens.pop(e2_end)
|
216 |
+
e1_start = tokens.index("<e1>")
|
217 |
+
tokens.pop(e1_start)
|
218 |
+
e1_end = tokens.index("</e1>")
|
219 |
+
tokens.pop(e1_end)
|
220 |
|
221 |
# some examples, like train/1276 are invalid (empty head/tail), and
|
222 |
# yield non-sensical examples without this check
|
223 |
+
if e1_end > e1_start and e2_end > e2_start:
|
224 |
yield int(id_), {
|
225 |
"id": id_,
|
226 |
"token": tokens,
|
227 |
+
"e1_start": e1_start,
|
228 |
+
"e1_end": e1_end,
|
229 |
+
"e2_start": e2_start,
|
230 |
+
"e2_end": e2_end,
|
231 |
"relation": relation,
|
232 |
}
|
233 |
else:
|