Datasets:
Tasks:
Text Classification
Sub-tasks:
multi-class-classification
Languages:
English
Size:
100K<n<1M
ArXiv:
Tags:
relation extraction
License:
Update tacred.py
Browse files
tacred.py
CHANGED
|
@@ -72,6 +72,11 @@ Note 2: This Datasetreader changes the offsets of the following fields, to confo
|
|
| 72 |
- subj_end to subj_end + 1 (make end offset exclusive)
|
| 73 |
- oj_end to oj_end + 1 (make end offset exclusive)
|
| 74 |
- stanford_head to stanford_head - 1 (make head offsets 0-based)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
"""
|
| 76 |
|
| 77 |
_HOMEPAGE = "https://nlp.stanford.edu/projects/tacred/"
|
|
@@ -134,6 +139,33 @@ _CLASS_LABELS = [
|
|
| 134 |
"per:title",
|
| 135 |
]
|
| 136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 137 |
|
| 138 |
def convert_ptb_token(token: str) -> str:
|
| 139 |
"""Convert PTB tokens to normal tokens"""
|
|
@@ -181,7 +213,7 @@ class Tacred(datasets.GeneratorBasedBuilder):
|
|
| 181 |
"tokens": datasets.Sequence(datasets.Value("string")),
|
| 182 |
"subj_start": datasets.Value("int32"),
|
| 183 |
"subj_end": datasets.Value("int32"),
|
| 184 |
-
"subj_type": datasets.
|
| 185 |
"obj_start": datasets.Value("int32"),
|
| 186 |
"obj_end": datasets.Value("int32"),
|
| 187 |
"obj_type": datasets.Value("string"),
|
|
|
|
| 72 |
- subj_end to subj_end + 1 (make end offset exclusive)
|
| 73 |
- oj_end to oj_end + 1 (make end offset exclusive)
|
| 74 |
- stanford_head to stanford_head - 1 (make head offsets 0-based)
|
| 75 |
+
|
| 76 |
+
It also changes the names of some fields:
|
| 77 |
+
- token -> tokens
|
| 78 |
+
- stanford_ner -> ner_tags
|
| 79 |
+
- stanford_pos -> pos_tags
|
| 80 |
"""
|
| 81 |
|
| 82 |
_HOMEPAGE = "https://nlp.stanford.edu/projects/tacred/"
|
|
|
|
| 139 |
"per:title",
|
| 140 |
]
|
| 141 |
|
| 142 |
+
_NER_CLASS_LABELS = [
|
| 143 |
+
"LOCATION",
|
| 144 |
+
"ORGANIZATION",
|
| 145 |
+
"PERSON",
|
| 146 |
+
"DATE",
|
| 147 |
+
"MONEY",
|
| 148 |
+
"PERCENT",
|
| 149 |
+
"TIME",
|
| 150 |
+
"CAUSE_OF_DEATH",
|
| 151 |
+
"CITY",
|
| 152 |
+
"COUNTRY",
|
| 153 |
+
"CRIMINAL_CHARGE",
|
| 154 |
+
"EMAIL",
|
| 155 |
+
"HANDLE",
|
| 156 |
+
"IDEOLOGY",
|
| 157 |
+
"NATIONALITY",
|
| 158 |
+
"RELIGION",
|
| 159 |
+
"STATE_OR_PROVINCE",
|
| 160 |
+
"TITLE",
|
| 161 |
+
"URL",
|
| 162 |
+
"NUMBER",
|
| 163 |
+
"ORDINAL",
|
| 164 |
+
"MISC",
|
| 165 |
+
"DURATION",
|
| 166 |
+
"O"
|
| 167 |
+
]
|
| 168 |
+
|
| 169 |
|
| 170 |
def convert_ptb_token(token: str) -> str:
|
| 171 |
"""Convert PTB tokens to normal tokens"""
|
|
|
|
| 213 |
"tokens": datasets.Sequence(datasets.Value("string")),
|
| 214 |
"subj_start": datasets.Value("int32"),
|
| 215 |
"subj_end": datasets.Value("int32"),
|
| 216 |
+
"subj_type": datasets.ClassLabel(names=_NER_CLASS_LABELS),
|
| 217 |
"obj_start": datasets.Value("int32"),
|
| 218 |
"obj_end": datasets.Value("int32"),
|
| 219 |
"obj_type": datasets.Value("string"),
|