Upload erukaLabels.py
Browse files- erukaLabels.py +6 -3
erukaLabels.py
CHANGED
|
@@ -77,7 +77,7 @@ class Funsd(datasets.GeneratorBasedBuilder):
|
|
| 77 |
"bboxes": datasets.Sequence(datasets.Sequence(datasets.Value("int64"))),
|
| 78 |
"ner_tags": datasets.Sequence(
|
| 79 |
datasets.features.ClassLabel(
|
| 80 |
-
names=["O"
|
| 81 |
)
|
| 82 |
),
|
| 83 |
"image": datasets.features.Image(),
|
|
@@ -136,11 +136,14 @@ class Funsd(datasets.GeneratorBasedBuilder):
|
|
| 136 |
|
| 137 |
for item in ddata_path:
|
| 138 |
cur_line_bboxes = []
|
| 139 |
-
words, label = [item["content"]], "
|
| 140 |
if len(words) == 0:
|
| 141 |
continue
|
| 142 |
tokens.append(words[0])
|
| 143 |
-
|
|
|
|
|
|
|
|
|
|
| 144 |
cur_line_bboxes.append(normalize_bbox(item["polygon"], size))
|
| 145 |
|
| 146 |
cur_line_bboxes = self.get_line_bbox(cur_line_bboxes)
|
|
|
|
| 77 |
"bboxes": datasets.Sequence(datasets.Sequence(datasets.Value("int64"))),
|
| 78 |
"ner_tags": datasets.Sequence(
|
| 79 |
datasets.features.ClassLabel(
|
| 80 |
+
names=["O"]
|
| 81 |
)
|
| 82 |
),
|
| 83 |
"image": datasets.features.Image(),
|
|
|
|
| 136 |
|
| 137 |
for item in ddata_path:
|
| 138 |
cur_line_bboxes = []
|
| 139 |
+
words, label = [item["content"]], item["confidence"]
|
| 140 |
if len(words) == 0:
|
| 141 |
continue
|
| 142 |
tokens.append(words[0])
|
| 143 |
+
if isinstance(label, float):
|
| 144 |
+
ner_tags.append("O")
|
| 145 |
+
else:
|
| 146 |
+
ner_tags.append(label.upper())
|
| 147 |
cur_line_bboxes.append(normalize_bbox(item["polygon"], size))
|
| 148 |
|
| 149 |
cur_line_bboxes = self.get_line_bbox(cur_line_bboxes)
|