Update prepration.py
Browse files- prepration.py +3 -5
prepration.py
CHANGED
@@ -2,11 +2,10 @@ from itertools import groupby
|
|
2 |
from torch_snippets import *
|
3 |
from datasets import load_dataset
|
4 |
|
5 |
-
|
6 |
-
ds = load_dataset('darentang/sroie')
|
7 |
classes = ds['train'].features['ner_tags'].feature.names
|
8 |
|
9 |
-
def
|
10 |
x = AD(X)
|
11 |
words_with_labels = wwl = [(w, classes[l]) for w,l in zip(x.words, x.ner_tags)]
|
12 |
wwl = [i for i in wwl if i[1] != 'O']
|
@@ -14,7 +13,6 @@ def make_classes(X):
|
|
14 |
wwl = {cls: ' '.join(next(zip(*group))) for cls,group in groupby(wwl, key=lambda x: x[1])}
|
15 |
X['fields'] = wwl
|
16 |
return X
|
17 |
-
|
18 |
|
19 |
-
ds = ds.map(
|
20 |
ds.push_to_hub('sizhkhy/SROIE', commit_message="add fields as a new key")
|
|
|
2 |
from torch_snippets import *
|
3 |
from datasets import load_dataset
|
4 |
|
5 |
+
ds = load_dataset('not-lain/sroie')
|
|
|
6 |
classes = ds['train'].features['ner_tags'].feature.names
|
7 |
|
8 |
+
def make_fields(X):
|
9 |
x = AD(X)
|
10 |
words_with_labels = wwl = [(w, classes[l]) for w,l in zip(x.words, x.ner_tags)]
|
11 |
wwl = [i for i in wwl if i[1] != 'O']
|
|
|
13 |
wwl = {cls: ' '.join(next(zip(*group))) for cls,group in groupby(wwl, key=lambda x: x[1])}
|
14 |
X['fields'] = wwl
|
15 |
return X
|
|
|
16 |
|
17 |
+
ds = ds.map(make_fields)
|
18 |
ds.push_to_hub('sizhkhy/SROIE', commit_message="add fields as a new key")
|