Update scripts to use data.zip instead of local data.
Browse files- CAS.py +37 -29
- data.zip +2 -2
- data/CAS_neg.txt +0 -0
- data/CAS_spec.txt +0 -0
CAS.py
CHANGED
|
@@ -59,17 +59,24 @@ _HOMEPAGE = "https://clementdalloux.fr/?page_id=28"
|
|
| 59 |
|
| 60 |
_LICENSE = 'Data User Agreement'
|
| 61 |
|
|
|
|
|
|
|
|
|
|
| 62 |
class CAS(datasets.GeneratorBasedBuilder):
|
| 63 |
|
| 64 |
-
DEFAULT_CONFIG_NAME = "
|
| 65 |
|
| 66 |
BUILDER_CONFIGS = [
|
| 67 |
-
datasets.BuilderConfig(name="pos", version="1.0.0",
|
|
|
|
| 68 |
|
| 69 |
-
datasets.BuilderConfig(name="cls", version="1.0.0",
|
|
|
|
| 70 |
|
| 71 |
-
datasets.BuilderConfig(name="ner_spec", version="1.0.0",
|
| 72 |
-
|
|
|
|
|
|
|
| 73 |
]
|
| 74 |
|
| 75 |
def _info(self):
|
|
@@ -82,13 +89,20 @@ class CAS(datasets.GeneratorBasedBuilder):
|
|
| 82 |
"document_id": datasets.Value("string"),
|
| 83 |
"tokens": [datasets.Value("string")],
|
| 84 |
"lemmas": [datasets.Value("string")],
|
| 85 |
-
# "pos_tags": [datasets.Value("string")],
|
| 86 |
"pos_tags": [datasets.features.ClassLabel(
|
| 87 |
-
names
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
)],
|
| 89 |
}
|
| 90 |
)
|
| 91 |
-
|
| 92 |
elif self.config.name.find("cls") != -1:
|
| 93 |
|
| 94 |
features = datasets.Features(
|
|
@@ -96,13 +110,12 @@ class CAS(datasets.GeneratorBasedBuilder):
|
|
| 96 |
"id": datasets.Value("string"),
|
| 97 |
"document_id": datasets.Value("string"),
|
| 98 |
"tokens": [datasets.Value("string")],
|
| 99 |
-
# "label": datasets.Value("string"),
|
| 100 |
"label": datasets.features.ClassLabel(
|
| 101 |
-
names
|
| 102 |
),
|
| 103 |
}
|
| 104 |
)
|
| 105 |
-
|
| 106 |
elif self.config.name.find("ner") != -1:
|
| 107 |
|
| 108 |
if self.config.name.find("_spec") != -1:
|
|
@@ -116,9 +129,8 @@ class CAS(datasets.GeneratorBasedBuilder):
|
|
| 116 |
"document_id": datasets.Value("string"),
|
| 117 |
"tokens": [datasets.Value("string")],
|
| 118 |
"lemmas": [datasets.Value("string")],
|
| 119 |
-
# "ner_tags": [datasets.Value("string")],
|
| 120 |
"ner_tags": [datasets.features.ClassLabel(
|
| 121 |
-
names
|
| 122 |
)],
|
| 123 |
}
|
| 124 |
)
|
|
@@ -134,12 +146,8 @@ class CAS(datasets.GeneratorBasedBuilder):
|
|
| 134 |
|
| 135 |
def _split_generators(self, dl_manager):
|
| 136 |
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
else:
|
| 141 |
-
data_dir = self.config.data_dir
|
| 142 |
-
|
| 143 |
return [
|
| 144 |
datasets.SplitGenerator(
|
| 145 |
name=datasets.Split.TRAIN,
|
|
@@ -203,7 +211,7 @@ class CAS(datasets.GeneratorBasedBuilder):
|
|
| 203 |
id_doc, id_word, word, lemma, tag = splitted[0:5]
|
| 204 |
if len(splitted) >= 8:
|
| 205 |
tag = splitted[6]
|
| 206 |
-
|
| 207 |
if tag == "@card@":
|
| 208 |
print(splitted)
|
| 209 |
|
|
@@ -224,13 +232,13 @@ class CAS(datasets.GeneratorBasedBuilder):
|
|
| 224 |
id_words.append(id_word)
|
| 225 |
words.append(word)
|
| 226 |
lemmas.append(lemma)
|
| 227 |
-
POS_tags.append('B-'
|
| 228 |
|
| 229 |
dic = {
|
| 230 |
-
"id_docs":
|
| 231 |
"id_words": id_words,
|
| 232 |
-
"words":
|
| 233 |
-
"lemmas":
|
| 234 |
"POS_tags": POS_tags,
|
| 235 |
}
|
| 236 |
|
|
@@ -270,7 +278,7 @@ class CAS(datasets.GeneratorBasedBuilder):
|
|
| 270 |
continue
|
| 271 |
|
| 272 |
id_doc, id_word, word, lemma, _ = line.split("\t")[0:5]
|
| 273 |
-
tag = line.replace("\n","").split("\t")[-1]
|
| 274 |
|
| 275 |
if tag == "***" or tag == "_":
|
| 276 |
tag = "O"
|
|
@@ -288,10 +296,10 @@ class CAS(datasets.GeneratorBasedBuilder):
|
|
| 288 |
ner_tags.append(tag)
|
| 289 |
|
| 290 |
dic = {
|
| 291 |
-
"id_docs":
|
| 292 |
"id_words": id_words,
|
| 293 |
-
"words":
|
| 294 |
-
"lemmas":
|
| 295 |
"ner_tags": ner_tags,
|
| 296 |
}
|
| 297 |
|
|
@@ -384,4 +392,4 @@ class CAS(datasets.GeneratorBasedBuilder):
|
|
| 384 |
|
| 385 |
for r in all_res:
|
| 386 |
if r["id"] in allowed_ids:
|
| 387 |
-
yield r["id"], r
|
|
|
|
| 59 |
|
| 60 |
_LICENSE = 'Data User Agreement'
|
| 61 |
|
| 62 |
+
_URL = "data.zip"
|
| 63 |
+
|
| 64 |
+
|
| 65 |
class CAS(datasets.GeneratorBasedBuilder):
|
| 66 |
|
| 67 |
+
DEFAULT_CONFIG_NAME = "pos"
|
| 68 |
|
| 69 |
BUILDER_CONFIGS = [
|
| 70 |
+
datasets.BuilderConfig(name="pos", version="1.0.0",
|
| 71 |
+
description="The CAS corpora - POS Speculation task"),
|
| 72 |
|
| 73 |
+
datasets.BuilderConfig(name="cls", version="1.0.0",
|
| 74 |
+
description="The CAS corpora - CLS Negation / Speculation task"),
|
| 75 |
|
| 76 |
+
datasets.BuilderConfig(name="ner_spec", version="1.0.0",
|
| 77 |
+
description="The CAS corpora - NER Speculation task"),
|
| 78 |
+
datasets.BuilderConfig(name="ner_neg", version="1.0.0",
|
| 79 |
+
description="The CAS corpora - NER Negation task"),
|
| 80 |
]
|
| 81 |
|
| 82 |
def _info(self):
|
|
|
|
| 89 |
"document_id": datasets.Value("string"),
|
| 90 |
"tokens": [datasets.Value("string")],
|
| 91 |
"lemmas": [datasets.Value("string")],
|
|
|
|
| 92 |
"pos_tags": [datasets.features.ClassLabel(
|
| 93 |
+
names=[
|
| 94 |
+
'B-ABR', 'B-ADJ', 'B-ADV', 'B-DET:ART', 'B-DET:POS', 'B-INT',
|
| 95 |
+
'B-KON', 'B-NAM', 'B-NOM', 'B-NUM',
|
| 96 |
+
'B-PRO:DEM', 'B-PRO:IND', 'B-PRO:PER',
|
| 97 |
+
'B-PRO:REL', 'B-PRP', 'B-PRP:det', 'B-PUN', 'B-PUN:cit',
|
| 98 |
+
'B-SENT', 'B-SYM', 'B-VER:con', 'B-VER:cond', 'B-VER:futu',
|
| 99 |
+
'B-VER:impf', 'B-VER:infi', 'B-VER:pper', 'B-VER:ppre',
|
| 100 |
+
'B-VER:pres', 'B-VER:simp', 'B-VER:subi', 'B-VER:subp'
|
| 101 |
+
],
|
| 102 |
)],
|
| 103 |
}
|
| 104 |
)
|
| 105 |
+
|
| 106 |
elif self.config.name.find("cls") != -1:
|
| 107 |
|
| 108 |
features = datasets.Features(
|
|
|
|
| 110 |
"id": datasets.Value("string"),
|
| 111 |
"document_id": datasets.Value("string"),
|
| 112 |
"tokens": [datasets.Value("string")],
|
|
|
|
| 113 |
"label": datasets.features.ClassLabel(
|
| 114 |
+
names=['negation_speculation', 'negation', 'neutral', 'speculation'],
|
| 115 |
),
|
| 116 |
}
|
| 117 |
)
|
| 118 |
+
|
| 119 |
elif self.config.name.find("ner") != -1:
|
| 120 |
|
| 121 |
if self.config.name.find("_spec") != -1:
|
|
|
|
| 129 |
"document_id": datasets.Value("string"),
|
| 130 |
"tokens": [datasets.Value("string")],
|
| 131 |
"lemmas": [datasets.Value("string")],
|
|
|
|
| 132 |
"ner_tags": [datasets.features.ClassLabel(
|
| 133 |
+
names=names,
|
| 134 |
)],
|
| 135 |
}
|
| 136 |
)
|
|
|
|
| 146 |
|
| 147 |
def _split_generators(self, dl_manager):
|
| 148 |
|
| 149 |
+
data_dir = dl_manager.download_and_extract(_URL).rstrip("/")
|
| 150 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
return [
|
| 152 |
datasets.SplitGenerator(
|
| 153 |
name=datasets.Split.TRAIN,
|
|
|
|
| 211 |
id_doc, id_word, word, lemma, tag = splitted[0:5]
|
| 212 |
if len(splitted) >= 8:
|
| 213 |
tag = splitted[6]
|
| 214 |
+
|
| 215 |
if tag == "@card@":
|
| 216 |
print(splitted)
|
| 217 |
|
|
|
|
| 232 |
id_words.append(id_word)
|
| 233 |
words.append(word)
|
| 234 |
lemmas.append(lemma)
|
| 235 |
+
POS_tags.append(f'B-{tag}')
|
| 236 |
|
| 237 |
dic = {
|
| 238 |
+
"id_docs": np.array(list(map(int, id_docs))),
|
| 239 |
"id_words": id_words,
|
| 240 |
+
"words": words,
|
| 241 |
+
"lemmas": lemmas,
|
| 242 |
"POS_tags": POS_tags,
|
| 243 |
}
|
| 244 |
|
|
|
|
| 278 |
continue
|
| 279 |
|
| 280 |
id_doc, id_word, word, lemma, _ = line.split("\t")[0:5]
|
| 281 |
+
tag = line.replace("\n", "").split("\t")[-1]
|
| 282 |
|
| 283 |
if tag == "***" or tag == "_":
|
| 284 |
tag = "O"
|
|
|
|
| 296 |
ner_tags.append(tag)
|
| 297 |
|
| 298 |
dic = {
|
| 299 |
+
"id_docs": np.array(list(map(int, id_docs))),
|
| 300 |
"id_words": id_words,
|
| 301 |
+
"words": words,
|
| 302 |
+
"lemmas": lemmas,
|
| 303 |
"ner_tags": ner_tags,
|
| 304 |
}
|
| 305 |
|
|
|
|
| 392 |
|
| 393 |
for r in all_res:
|
| 394 |
if r["id"] in allowed_ids:
|
| 395 |
+
yield r["id"], r
|
data.zip
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fbf074c8034354f28d9909ac6f6339acb5d4e556dadca5cbe6e19fb0a85e7696
|
| 3 |
+
size 1183523
|
data/CAS_neg.txt
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/CAS_spec.txt
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|