add fileState.txt
Browse files- main.py +14 -3
- pdfs/jp/高木直子学日语文法不要想太多/fileState.txt +3 -0
main.py
CHANGED
|
@@ -189,9 +189,10 @@ def ocr_one_pdf(pth_pdf):
|
|
| 189 |
name_pp_state = 'fileState.txt'
|
| 190 |
pth_pp_state = os.path.join(dir, name_pp_state)
|
| 191 |
pp_state_text = ''
|
| 192 |
-
#
|
| 193 |
-
|
| 194 |
|
|
|
|
| 195 |
for nth_page in range(1, number_of_pages+1):
|
| 196 |
|
| 197 |
if nth_page > 300:
|
|
@@ -220,7 +221,10 @@ def ocr_one_pdf(pth_pdf):
|
|
| 220 |
|
| 221 |
label_left = f'{Path(dir).stem}/{img_name}' # for ppocrlabel
|
| 222 |
label_right = []
|
| 223 |
-
|
|
|
|
|
|
|
|
|
|
| 224 |
jsn = None
|
| 225 |
|
| 226 |
if not os.path.exists(pth_jsn):
|
|
@@ -300,6 +304,13 @@ def ocr_one_pdf(pth_pdf):
|
|
| 300 |
with open(pth_pp_label, 'w', encoding='utf-8') as f:
|
| 301 |
f.write(pp_label_text)
|
| 302 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 303 |
|
| 304 |
if __name__ == '__main__':
|
| 305 |
|
|
|
|
| 189 |
name_pp_state = 'fileState.txt'
|
| 190 |
pth_pp_state = os.path.join(dir, name_pp_state)
|
| 191 |
pp_state_text = ''
|
| 192 |
+
# E:\huggingface\pdf_ocr\pdfs\jp\高木直子学日语文法不要想太多\0010.jpg 1
|
| 193 |
+
# 只能在 windows 平台用绝对路径
|
| 194 |
|
| 195 |
+
|
| 196 |
for nth_page in range(1, number_of_pages+1):
|
| 197 |
|
| 198 |
if nth_page > 300:
|
|
|
|
| 221 |
|
| 222 |
label_left = f'{Path(dir).stem}/{img_name}' # for ppocrlabel
|
| 223 |
label_right = []
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
pp_state_text += 'E:\\huggingface\\'+ dir.replace('/', '\\') + '\\' + "{:04d}.jpg".format(nth_page) + '\t' + '1\n'
|
| 227 |
+
|
| 228 |
jsn = None
|
| 229 |
|
| 230 |
if not os.path.exists(pth_jsn):
|
|
|
|
| 304 |
with open(pth_pp_label, 'w', encoding='utf-8') as f:
|
| 305 |
f.write(pp_label_text)
|
| 306 |
|
| 307 |
+
if not os.path.exists(pth_pp_state):
|
| 308 |
+
# if exist, maybe ppocrlabel edited already. DO NOT rewrite it!!!
|
| 309 |
+
if pp_state_text:
|
| 310 |
+
with open(pth_pp_state, 'w', encoding='utf-8') as f:
|
| 311 |
+
f.write(pp_state_text)
|
| 312 |
+
|
| 313 |
+
|
| 314 |
|
| 315 |
if __name__ == '__main__':
|
| 316 |
|
pdfs/jp/高木直子学日语文法不要想太多/fileState.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7cd61100fef8219ac82daf185adb6f00e41550c09047377d3850dca57187c578
|
| 3 |
+
size 13244
|