ramybaly
commited on
Commit
·
9ada35a
1
Parent(s):
ad5cea2
fixed bug in dataset script
Browse files- id2coarse_tags.json +2 -2
- nerd.py +74 -74
- prepare_data.py +9 -6
- test.txt +2 -2
- train.txt +2 -2
- validation.txt +2 -2
id2coarse_tags.json
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:0a8f2b723f940c3bcfc2422fedd824fbd92f0126f4f7f38866edb0b376bbaa29
|
| 3 |
+
size 134
|
nerd.py
CHANGED
|
@@ -70,82 +70,82 @@ class NERD(datasets.GeneratorBasedBuilder):
|
|
| 70 |
"tokens": datasets.Sequence(datasets.Value("string")),
|
| 71 |
"ner_tags": datasets.Sequence(
|
| 72 |
datasets.features.ClassLabel(
|
| 73 |
-
names=['O', 'I-
|
| 74 |
-
)
|
| 75 |
-
),
|
| 76 |
-
"ner_tags_fine": datasets.Sequence(
|
| 77 |
-
datasets.features.ClassLabel(
|
| 78 |
-
names=[
|
| 79 |
-
'O',
|
| 80 |
-
'I-art-broadcastprogram',
|
| 81 |
-
'I-art-film',
|
| 82 |
-
'I-art-music',
|
| 83 |
-
'I-art-other',
|
| 84 |
-
'I-art-painting',
|
| 85 |
-
'I-art-writtenart',
|
| 86 |
-
'I-building-airport',
|
| 87 |
-
'I-building-hospital',
|
| 88 |
-
'I-building-hotel',
|
| 89 |
-
'I-building-library',
|
| 90 |
-
'I-building-other',
|
| 91 |
-
'I-building-restaurant',
|
| 92 |
-
'I-building-sportsfacility',
|
| 93 |
-
'I-building-theater',
|
| 94 |
-
'I-event-attack/battle/war/militaryconflict',
|
| 95 |
-
'I-event-disaster',
|
| 96 |
-
'I-event-election',
|
| 97 |
-
'I-event-other',
|
| 98 |
-
'I-event-protest',
|
| 99 |
-
'I-event-sportsevent',
|
| 100 |
-
'I-location-GPE',
|
| 101 |
-
'I-location-bodiesofwater',
|
| 102 |
-
'I-location-island',
|
| 103 |
-
'I-location-mountain',
|
| 104 |
-
'I-location-other',
|
| 105 |
-
'I-location-park',
|
| 106 |
-
'I-location-road/railway/highway/transit',
|
| 107 |
-
'I-organization-company',
|
| 108 |
-
'I-organization-education',
|
| 109 |
-
'I-organization-government/governmentagency',
|
| 110 |
-
'I-organization-media/newspaper',
|
| 111 |
-
'I-organization-other',
|
| 112 |
-
'I-organization-politicalparty',
|
| 113 |
-
'I-organization-religion',
|
| 114 |
-
'I-organization-showorganization',
|
| 115 |
-
'I-organization-sportsleague',
|
| 116 |
-
'I-organization-sportsteam',
|
| 117 |
-
'I-other-astronomything',
|
| 118 |
-
'I-other-award',
|
| 119 |
-
'I-other-biologything',
|
| 120 |
-
'I-other-chemicalthing',
|
| 121 |
-
'I-other-currency',
|
| 122 |
-
'I-other-disease',
|
| 123 |
-
'I-other-educationaldegree',
|
| 124 |
-
'I-other-god',
|
| 125 |
-
'I-other-language',
|
| 126 |
-
'I-other-law',
|
| 127 |
-
'I-other-livingthing',
|
| 128 |
-
'I-other-medical',
|
| 129 |
-
'I-person-actor',
|
| 130 |
-
'I-person-artist/author',
|
| 131 |
-
'I-person-athlete',
|
| 132 |
-
'I-person-director',
|
| 133 |
-
'I-person-other',
|
| 134 |
-
'I-person-politician',
|
| 135 |
-
'I-person-scholar',
|
| 136 |
-
'I-person-soldier',
|
| 137 |
-
'I-product-airplane',
|
| 138 |
-
'I-product-car',
|
| 139 |
-
'I-product-food',
|
| 140 |
-
'I-product-game',
|
| 141 |
-
'I-product-other',
|
| 142 |
-
'I-product-ship',
|
| 143 |
-
'I-product-software',
|
| 144 |
-
'I-product-train',
|
| 145 |
-
'I-product-weapon'
|
| 146 |
-
]
|
| 147 |
)
|
| 148 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
}
|
| 150 |
),
|
| 151 |
supervised_keys=None,
|
|
|
|
| 70 |
"tokens": datasets.Sequence(datasets.Value("string")),
|
| 71 |
"ner_tags": datasets.Sequence(
|
| 72 |
datasets.features.ClassLabel(
|
| 73 |
+
names=['O', 'I-ART', 'I-BUILDING', 'I-EVENT', 'I-LOC', 'I-ORG', 'I-MISC', 'I-PER', 'I-PRODUCT']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
)
|
| 75 |
),
|
| 76 |
+
# "ner_tags_fine": datasets.Sequence(
|
| 77 |
+
# datasets.features.ClassLabel(
|
| 78 |
+
# names=[
|
| 79 |
+
# 'O',
|
| 80 |
+
# 'I-art-broadcastprogram',
|
| 81 |
+
# 'I-art-film',
|
| 82 |
+
# 'I-art-music',
|
| 83 |
+
# 'I-art-other',
|
| 84 |
+
# 'I-art-painting',
|
| 85 |
+
# 'I-art-writtenart',
|
| 86 |
+
# 'I-building-airport',
|
| 87 |
+
# 'I-building-hospital',
|
| 88 |
+
# 'I-building-hotel',
|
| 89 |
+
# 'I-building-library',
|
| 90 |
+
# 'I-building-other',
|
| 91 |
+
# 'I-building-restaurant',
|
| 92 |
+
# 'I-building-sportsfacility',
|
| 93 |
+
# 'I-building-theater',
|
| 94 |
+
# 'I-event-attack/battle/war/militaryconflict',
|
| 95 |
+
# 'I-event-disaster',
|
| 96 |
+
# 'I-event-election',
|
| 97 |
+
# 'I-event-other',
|
| 98 |
+
# 'I-event-protest',
|
| 99 |
+
# 'I-event-sportsevent',
|
| 100 |
+
# 'I-location-GPE',
|
| 101 |
+
# 'I-location-bodiesofwater',
|
| 102 |
+
# 'I-location-island',
|
| 103 |
+
# 'I-location-mountain',
|
| 104 |
+
# 'I-location-other',
|
| 105 |
+
# 'I-location-park',
|
| 106 |
+
# 'I-location-road/railway/highway/transit',
|
| 107 |
+
# 'I-organization-company',
|
| 108 |
+
# 'I-organization-education',
|
| 109 |
+
# 'I-organization-government/governmentagency',
|
| 110 |
+
# 'I-organization-media/newspaper',
|
| 111 |
+
# 'I-organization-other',
|
| 112 |
+
# 'I-organization-politicalparty',
|
| 113 |
+
# 'I-organization-religion',
|
| 114 |
+
# 'I-organization-showorganization',
|
| 115 |
+
# 'I-organization-sportsleague',
|
| 116 |
+
# 'I-organization-sportsteam',
|
| 117 |
+
# 'I-other-astronomything',
|
| 118 |
+
# 'I-other-award',
|
| 119 |
+
# 'I-other-biologything',
|
| 120 |
+
# 'I-other-chemicalthing',
|
| 121 |
+
# 'I-other-currency',
|
| 122 |
+
# 'I-other-disease',
|
| 123 |
+
# 'I-other-educationaldegree',
|
| 124 |
+
# 'I-other-god',
|
| 125 |
+
# 'I-other-language',
|
| 126 |
+
# 'I-other-law',
|
| 127 |
+
# 'I-other-livingthing',
|
| 128 |
+
# 'I-other-medical',
|
| 129 |
+
# 'I-person-actor',
|
| 130 |
+
# 'I-person-artist/author',
|
| 131 |
+
# 'I-person-athlete',
|
| 132 |
+
# 'I-person-director',
|
| 133 |
+
# 'I-person-other',
|
| 134 |
+
# 'I-person-politician',
|
| 135 |
+
# 'I-person-scholar',
|
| 136 |
+
# 'I-person-soldier',
|
| 137 |
+
# 'I-product-airplane',
|
| 138 |
+
# 'I-product-car',
|
| 139 |
+
# 'I-product-food',
|
| 140 |
+
# 'I-product-game',
|
| 141 |
+
# 'I-product-other',
|
| 142 |
+
# 'I-product-ship',
|
| 143 |
+
# 'I-product-software',
|
| 144 |
+
# 'I-product-train',
|
| 145 |
+
# 'I-product-weapon'
|
| 146 |
+
# ]
|
| 147 |
+
# )
|
| 148 |
+
# ),
|
| 149 |
}
|
| 150 |
),
|
| 151 |
supervised_keys=None,
|
prepare_data.py
CHANGED
|
@@ -5,7 +5,7 @@ import pickle
|
|
| 5 |
|
| 6 |
def main():
|
| 7 |
id2label = {int(i): tag for i, tag in json.load(open('./id2coarse_tags.json', 'r')).items()}
|
| 8 |
-
id2label_fine = {int(i): tag for i, tag in json.load(open('./id2fine_tags.json', 'r')).items()}
|
| 9 |
|
| 10 |
files = glob.glob('./*json')
|
| 11 |
|
|
@@ -23,12 +23,15 @@ def main():
|
|
| 23 |
ner_tags_ids = sentence['coarse_tags']
|
| 24 |
ner_tags_fine_ids = sentence['fine_tags']
|
| 25 |
|
| 26 |
-
ner_tags = [
|
| 27 |
-
ner_tags_fine = ['-'.join(['I', id2label_fine[t]]) if id2label_fine[t] != 'O' else id2label[t] for t in ner_tags_fine_ids]
|
| 28 |
-
|
| 29 |
-
for token, tag, tag_fine in zip(tokens, ner_tags, ner_tags_fine):
|
| 30 |
-
f.write(f'{token}\t{tag}\t{tag_fine}\n')
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
f.write('\n')
|
| 33 |
|
| 34 |
|
|
|
|
| 5 |
|
| 6 |
def main():
|
| 7 |
id2label = {int(i): tag for i, tag in json.load(open('./id2coarse_tags.json', 'r')).items()}
|
| 8 |
+
# id2label_fine = {int(i): tag for i, tag in json.load(open('./id2fine_tags.json', 'r')).items()}
|
| 9 |
|
| 10 |
files = glob.glob('./*json')
|
| 11 |
|
|
|
|
| 23 |
ner_tags_ids = sentence['coarse_tags']
|
| 24 |
ner_tags_fine_ids = sentence['fine_tags']
|
| 25 |
|
| 26 |
+
ner_tags = [id2label[t] for t in ner_tags_ids]
|
| 27 |
+
# ner_tags_fine = ['-'.join(['I', id2label_fine[t]]) if id2label_fine[t] != 'O' else id2label[t] for t in ner_tags_fine_ids]
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
# for token, tag, tag_fine in zip(tokens, ner_tags, ner_tags_fine):
|
| 30 |
+
# f.write(f'{token}\t{tag}\t{tag_fine}\n')
|
| 31 |
+
|
| 32 |
+
for token, tag in zip(tokens, ner_tags):
|
| 33 |
+
f.write(f'{token}\t{tag}\n')
|
| 34 |
+
|
| 35 |
f.write('\n')
|
| 36 |
|
| 37 |
|
test.txt
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:cfc3d935eb96b72f8f0014de6e21467fbdbaad1675ae6e56189acd0b2db0185a
|
| 3 |
+
size 7878894
|
train.txt
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:4dba55486479f62f0f7e7150f046edc532effb4e91a9570586cbc31af04e074b
|
| 3 |
+
size 27615430
|
validation.txt
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:9201e711390f19a0301eb0a36b690aa13b68e3e476052f15cd5ef9e4cfa79a45
|
| 3 |
+
size 3960928
|