fasdfsa commited on
Commit
ee034c2
·
1 Parent(s): 591870f

fix exinfo.py

Browse files
Files changed (1) hide show
  1. exinfo.py +19 -15
exinfo.py CHANGED
@@ -51,8 +51,11 @@ if __name__ == '__main__':
51
  sign_count = 0
52
  stem = Path(pt).stem
53
  pageId = pageNames_pageIds[stem]
54
- page_text = page_texts[pageId]
55
- page_text = page_text.replace(' ', '')
 
 
 
56
  pt_boxsnew = pt.replace('.boxs', '.boxsnew')
57
 
58
  if os.path.exists(pt_boxsnew):
@@ -73,7 +76,7 @@ if __name__ == '__main__':
73
  charText = variants[charText]
74
  charText = s2t.convert(charText)
75
  g = k + sign_count
76
- if page_text[g] in signs:
77
  sign = page_text[g]
78
  # 把符号加到前一个字
79
  box[k-1]["sign"] = sign
@@ -81,22 +84,23 @@ if __name__ == '__main__':
81
  sign_count += 1
82
  g = k + sign_count
83
 
84
- if page_text[g] in variants: # 异体
85
  before = page_text[:g]
86
  after = page_text[g+1:]
87
  oldchar = page_text[g]
88
  newchar = variants[oldchar]
89
  page_text = before + newchar + after
90
-
91
- before = page_text[:g]
92
- after = page_text[g+1:]
93
- oldchar = page_text[g]
94
- newchar = s2t.convert(oldchar) # 简繁
95
- page_text = before + newchar + after
96
- if page_text[g] == charText:
97
- pass
98
- else:
99
- pass
 
100
  lu = [charPoly["x0"], charPoly["y0"]]
101
  ru = [charPoly["x1"], charPoly["y1"]]
102
  rd = [charPoly["x2"], charPoly["y2"]]
@@ -154,5 +158,5 @@ if __name__ == '__main__':
154
 
155
  print(f"box {j+1} / {len(boxs)}")
156
 
157
- print(f"{chapter} {i+1} / {len(pths)}")
158
 
 
51
  sign_count = 0
52
  stem = Path(pt).stem
53
  pageId = pageNames_pageIds[stem]
54
+ if pageId not in page_texts:
55
+ page_text = ''
56
+ else:
57
+ page_text = page_texts[pageId]
58
+ page_text = page_text.replace(' ', '')
59
  pt_boxsnew = pt.replace('.boxs', '.boxsnew')
60
 
61
  if os.path.exists(pt_boxsnew):
 
76
  charText = variants[charText]
77
  charText = s2t.convert(charText)
78
  g = k + sign_count
79
+ if page_text and page_text[g] in signs:
80
  sign = page_text[g]
81
  # 把符号加到前一个字
82
  box[k-1]["sign"] = sign
 
84
  sign_count += 1
85
  g = k + sign_count
86
 
87
+ if page_text and page_text[g] in variants: # 异体
88
  before = page_text[:g]
89
  after = page_text[g+1:]
90
  oldchar = page_text[g]
91
  newchar = variants[oldchar]
92
  page_text = before + newchar + after
93
+
94
+ if page_text:
95
+ before = page_text[:g]
96
+ after = page_text[g+1:]
97
+ oldchar = page_text[g]
98
+ newchar = s2t.convert(oldchar) # 简繁
99
+ page_text = before + newchar + after
100
+ if page_text[g] == charText:
101
+ pass
102
+ else:
103
+ pass
104
  lu = [charPoly["x0"], charPoly["y0"]]
105
  ru = [charPoly["x1"], charPoly["y1"]]
106
  rd = [charPoly["x2"], charPoly["y2"]]
 
158
 
159
  print(f"box {j+1} / {len(boxs)}")
160
 
161
+ print(f"{chapter} {i+1} / {len(chs)}")
162