소스 검색

修复补span的问题

luojiehua 3 년 전
부모
커밋
bfe7053c92
1개의 변경된 파일35개의 추가작업 그리고 16개의 파일을 삭제
  1. 35 16
      format_convert/utils.py

+ 35 - 16
format_convert/utils.py

@@ -723,14 +723,14 @@ class LineTable:
                         exists,point = self.cross_point(line1,line2)
                         exists,point = self.cross_point(line1,line2)
                         if exists:
                         if exists:
                             list_crosspoints.append(point)
                             list_crosspoints.append(point)
-                # from matplotlib import pyplot as plt
-                # plt.figure()
-                # for _line in l_lines:
-                #     x0,y0,x1,y1 = _line
-                #     plt.plot([x0,x1],[y0,y1])
-                # for point in list_crosspoints:
-                #     plt.scatter(point.get("point")[0],point.get("point")[1])
-                # plt.show()
+                from matplotlib import pyplot as plt
+                plt.figure()
+                for _line in l_lines:
+                    x0,y0,x1,y1 = _line
+                    plt.plot([x0,x1],[y0,y1])
+                for point in list_crosspoints:
+                    plt.scatter(point.get("point")[0],point.get("point")[1])
+                plt.show()
 
 
         # print(list_crosspoints)
         # print(list_crosspoints)
         # print("points num",len(list_crosspoints))
         # print("points num",len(list_crosspoints))
@@ -1139,11 +1139,14 @@ class LineTable:
             for _line in _table:
             for _line in _table:
                 for c_i in range(len(_line)):
                 for c_i in range(len(_line)):
                     _cell = _line[c_i]
                     _cell = _line[c_i]
+
                     if _cell.get("columnspan")>1:
                     if _cell.get("columnspan")>1:
                         _cospan = _cell.get("columnspan")
                         _cospan = _cell.get("columnspan")
                         _cell["columnspan"] = 1
                         _cell["columnspan"] = 1
+                        n_cell = {}
+                        n_cell.update(_cell)
                         for i in range(1,_cospan):
                         for i in range(1,_cospan):
-                            _line.insert(c_i,_cell)
+                            _line.insert(c_i,n_cell)
             for l_i in range(len(_table)):
             for l_i in range(len(_table)):
                 _line = _table[l_i]
                 _line = _table[l_i]
                 for c_i in range(len(_line)):
                 for c_i in range(len(_line)):
@@ -1151,10 +1154,23 @@ class LineTable:
                     if _cell.get("rowspan")>1:
                     if _cell.get("rowspan")>1:
                         _rospan = _cell.get("rowspan")
                         _rospan = _cell.get("rowspan")
                         _cell["rowspan"] = 1
                         _cell["rowspan"] = 1
+                        n_cell = {}
+                        n_cell.update(_cell)
                         for i in range(1,_rospan):
                         for i in range(1,_rospan):
                             if l_i+i<=len(_table)-1:
                             if l_i+i<=len(_table)-1:
                                 # print(len(_table),l_i+i)
                                 # print(len(_table),l_i+i)
-                                _table[l_i+i].insert(c_i,_cell)
+                                _table[l_i+i].insert(c_i,n_cell)
+
+
+        print("=======")
+        for _line in _table:
+            for _cell in _line:
+                _text = _cell["text"][:2]+"_"+str(_cell["columnspan"])+"_"+str(_cell["rowspan"])
+                if _text=="":
+                    _text = "=="
+                print(_text,end="\t")
+            print("\n")
+        print("===========")
 
 
         if fixRect:
         if fixRect:
             for _line in _table:
             for _line in _table:
@@ -1223,12 +1239,15 @@ class LineTable:
 
 
 
 
 
 
-        # print("=======")
-        # for _line in _table:
-        #     for _cell in _line:
-        #         print(_cell,end="\t\t")
-        #     print("\n")
-        # print("===========")
+        print("=======")
+        for _line in _table:
+            for _cell in _line:
+                _text = _cell["text"][:2]
+                if _text=="":
+                    _text = "=="
+                print(_text,end="\t")
+            print("\n")
+        print("===========")
 
 
         table_bbox = (_table[0][0].get("bbox")[0],
         table_bbox = (_table[0][0].get("bbox")[0],
                       _table[0][0].get("bbox")[1],
                       _table[0][0].get("bbox")[1],