Update layout_documents.py
Browse files- layout_documents.py +3 -6
layout_documents.py
CHANGED
|
@@ -69,7 +69,7 @@ class LayoutLM(datasets.GeneratorBasedBuilder):
|
|
| 69 |
"bboxes": datasets.Sequence(datasets.Sequence(datasets.Value("int64"))),
|
| 70 |
"ner_tags": datasets.Sequence(
|
| 71 |
datasets.features.ClassLabel(
|
| 72 |
-
names=["O", "HEADER","SUBHEADER", "TEXTO", "NUMERAL", "RESUMEN"]
|
| 73 |
)
|
| 74 |
),
|
| 75 |
"image": datasets.features.Image(),
|
|
@@ -87,9 +87,6 @@ class LayoutLM(datasets.GeneratorBasedBuilder):
|
|
| 87 |
datasets.SplitGenerator(
|
| 88 |
name=datasets.Split.TRAIN, gen_kwargs={"filepath": f"{downloaded_file}/dataset/training_data/"}
|
| 89 |
),
|
| 90 |
-
datasets.SplitGenerator(
|
| 91 |
-
name=datasets.Split.TEST, gen_kwargs={"filepath": f"{downloaded_file}/dataset/testing_data/"}
|
| 92 |
-
),
|
| 93 |
]
|
| 94 |
|
| 95 |
def get_line_bbox(self, bboxs):
|
|
@@ -130,11 +127,11 @@ class LayoutLM(datasets.GeneratorBasedBuilder):
|
|
| 130 |
cur_line_bboxes.append(normalize_bbox(w["box"], size))
|
| 131 |
else:
|
| 132 |
tokens.append(words[0]["text"])
|
| 133 |
-
ner_tags.append(label.upper())
|
| 134 |
cur_line_bboxes.append(normalize_bbox(words[0]["box"], size))
|
| 135 |
for w in words[1:]:
|
| 136 |
tokens.append(w["text"])
|
| 137 |
-
ner_tags.append(label.upper())
|
| 138 |
cur_line_bboxes.append(normalize_bbox(w["box"], size))
|
| 139 |
cur_line_bboxes = self.get_line_bbox(cur_line_bboxes)
|
| 140 |
bboxes.extend(cur_line_bboxes)
|
|
|
|
| 69 |
"bboxes": datasets.Sequence(datasets.Sequence(datasets.Value("int64"))),
|
| 70 |
"ner_tags": datasets.Sequence(
|
| 71 |
datasets.features.ClassLabel(
|
| 72 |
+
names=["O", "B-HEADER", "I-HEADER","B-SUBHEADER", "I-SUBHEADER","B-TEXTO", "I-TEXTO","B-NUMERAL", "I-NUMERAL", "B-RESUMEN", "I-RESUMEN"]
|
| 73 |
)
|
| 74 |
),
|
| 75 |
"image": datasets.features.Image(),
|
|
|
|
| 87 |
datasets.SplitGenerator(
|
| 88 |
name=datasets.Split.TRAIN, gen_kwargs={"filepath": f"{downloaded_file}/dataset/training_data/"}
|
| 89 |
),
|
|
|
|
|
|
|
|
|
|
| 90 |
]
|
| 91 |
|
| 92 |
def get_line_bbox(self, bboxs):
|
|
|
|
| 127 |
cur_line_bboxes.append(normalize_bbox(w["box"], size))
|
| 128 |
else:
|
| 129 |
tokens.append(words[0]["text"])
|
| 130 |
+
ner_tags.append("B-" + label.upper())
|
| 131 |
cur_line_bboxes.append(normalize_bbox(words[0]["box"], size))
|
| 132 |
for w in words[1:]:
|
| 133 |
tokens.append(w["text"])
|
| 134 |
+
ner_tags.append("I-" + label.upper())
|
| 135 |
cur_line_bboxes.append(normalize_bbox(w["box"], size))
|
| 136 |
cur_line_bboxes = self.get_line_bbox(cur_line_bboxes)
|
| 137 |
bboxes.extend(cur_line_bboxes)
|