File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change 13
13
from functools import cmp_to_key
14
14
from typing import Any , Dict , List , Tuple
15
15
16
+ import numpy as np
16
17
from pdfminer .layout import LTFigure , LTTextLine
17
18
from pdfminer .utils import Plane
18
19
@@ -1274,11 +1275,8 @@ def get_page_width(boxes):
1274
1275
1275
1276
1276
1277
def get_char_width (boxes : List [LTTextLine ]) -> float :
1277
- box_len_sum = 0
1278
- num_char_sum = 0
1279
- for i , b in enumerate (boxes ):
1280
- box_len_sum = box_len_sum + b .bbox [2 ] - b .bbox [0 ]
1281
- num_char_sum = num_char_sum + len (b .get_text ())
1278
+ box_len_sum = np .sum ([b .bbox [2 ] - b .bbox [0 ] for b in boxes ])
1279
+ num_char_sum = np .sum ([len (b .get_text ()) for b in boxes ])
1282
1280
try :
1283
1281
return box_len_sum / num_char_sum
1284
1282
except ZeroDivisionError :
You can’t perform that action at this time.
0 commit comments