|
6 | 6 | # @Mailbox : jadehh@live.com |
7 | 7 | # @Software: Samples |
8 | 8 | # @Desc : |
| 9 | +import os.path |
| 10 | + |
9 | 11 | from jade import * |
10 | 12 | import json |
11 | 13 | import base64 |
@@ -175,20 +177,23 @@ def createDatasets(root_path): |
175 | 177 | with open(os.path.join(root_path, "train_icdar2015_label.txt"), "wb") as f1: |
176 | 178 | for year in years: |
177 | 179 | if len(year.split("-")) > 1 and os.path.isdir(os.path.join(root_path, year)): |
178 | | - with open(os.path.join(root_path, year, "train_icdar2015_label.txt"), "rb") as f: |
179 | | - content_list = f.readlines() |
180 | | - for content in content_list: |
181 | | - new_c = year + "/" + str(content,encoding="utf-8").strip() |
182 | | - f1.write((new_c + "\n").encode("utf-8")) |
| 180 | + if os.path.exists(os.path.join(root_path, year, "train_icdar2015_label.txt")): |
| 181 | + with open(os.path.join(root_path, year, "train_icdar2015_label.txt"), "rb") as f: |
| 182 | + content_list = f.readlines() |
| 183 | + for content in content_list: |
| 184 | + new_c = year + "/" + str(content, encoding="utf-8").strip() |
| 185 | + f1.write((new_c + "\n").encode("utf-8")) |
183 | 186 |
|
184 | 187 | with open(os.path.join(root_path, "test_icdar2015_label.txt"), "wb") as f1: |
185 | 188 | for year in years: |
186 | 189 | if len(year.split("-")) > 1 and os.path.isdir(os.path.join(root_path, year)): |
187 | | - with open(os.path.join(root_path, year, "test_icdar2015_label.txt"), "rb") as f: |
188 | | - content_list = f.readlines() |
189 | | - for content in content_list: |
190 | | - new_c = year + "/" + str(content,encoding="utf-8").strip() |
191 | | - f1.write((new_c + "\n").encode("utf-8")) |
| 190 | + if os.path.exists(os.path.join(root_path, year, "test_icdar2015_label.txt")): |
| 191 | + with open(os.path.join(root_path, year, "test_icdar2015_label.txt"), "rb") as f: |
| 192 | + content_list = f.readlines() |
| 193 | + for content in content_list: |
| 194 | + new_c = year + "/" + str(content, encoding="utf-8").strip() |
| 195 | + f1.write((new_c + "\n").encode("utf-8")) |
| 196 | + |
192 | 197 |
|
193 | 198 |
|
194 | 199 | def removeNolabelDatasets(root_path): |
|
0 commit comments