Fix plot_text
parent
3170a9689f
commit
71d91fbebd
|
|
@ -333,7 +333,8 @@ class Table(object):
|
|||
|
||||
"""
|
||||
if self.flavor == 'stream' and geometry_type in ['contour', 'joint', 'line']:
|
||||
raise NotImplementedError("{} cannot be plotted with flavor='stream'")
|
||||
raise NotImplementedError("{} cannot be plotted with flavor='stream'".format(
|
||||
geometry_type))
|
||||
|
||||
if geometry_type == 'text':
|
||||
plot_text(self._text)
|
||||
|
|
@ -444,13 +445,25 @@ class TableList(object):
|
|||
def __getitem__(self, idx):
|
||||
return self._tables[idx]
|
||||
|
||||
def __iter__(self):
|
||||
self._n = 0
|
||||
return self
|
||||
|
||||
def next(self):
|
||||
if self._n < len(self):
|
||||
r = self._tables[self._n]
|
||||
self._n += 1
|
||||
return r
|
||||
else:
|
||||
raise StopIteration
|
||||
|
||||
@staticmethod
|
||||
def _format_func(table, f):
|
||||
return getattr(table, 'to_{}'.format(f))
|
||||
|
||||
@property
|
||||
def n(self):
|
||||
return len(self._tables)
|
||||
return len(self)
|
||||
|
||||
def _write_file(self, f=None, **kwargs):
|
||||
dirname = kwargs.get('dirname')
|
||||
|
|
|
|||
|
|
@ -88,5 +88,5 @@ def read_pdf(filepath, pages='1', flavor='lattice', **kwargs):
|
|||
validate_input(kwargs, flavor=flavor)
|
||||
p = PDFHandler(filepath, pages)
|
||||
kwargs = remove_extra(kwargs, flavor=flavor)
|
||||
tables, __ = p.parse(flavor=flavor, **kwargs)
|
||||
tables = p.parse(flavor=flavor, **kwargs)
|
||||
return tables
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
import os
|
||||
|
||||
from ..core import Geometry
|
||||
from ..utils import get_page_layout, get_text_objects
|
||||
|
||||
|
||||
|
|
@ -17,5 +16,4 @@ class BaseParser(object):
|
|||
self.horizontal_text = get_text_objects(self.layout, ltype="lh")
|
||||
self.vertical_text = get_text_objects(self.layout, ltype="lv")
|
||||
self.pdf_width, self.pdf_height = self.dimensions
|
||||
self.rootname, __ = os.path.splitext(self.filename)
|
||||
self.g = Geometry()
|
||||
self.rootname, __ = os.path.splitext(self.filename)
|
||||
|
|
@ -8,8 +8,8 @@ def plot_text(text):
|
|||
ax = fig.add_subplot(111, aspect='equal')
|
||||
xs, ys = [], []
|
||||
for t in text:
|
||||
xs.extend([t[0], t[1]])
|
||||
ys.extend([t[2], t[3]])
|
||||
xs.extend([t[0], t[2]])
|
||||
ys.extend([t[1], t[3]])
|
||||
ax.add_patch(
|
||||
patches.Rectangle(
|
||||
(t[0], t[1]),
|
||||
|
|
@ -57,9 +57,7 @@ def plot_joint(image):
|
|||
for coord in table_bbox[k]:
|
||||
x_coord.append(coord[0])
|
||||
y_coord.append(coord[1])
|
||||
max_x, max_y = max(x_coord), max(y_coord)
|
||||
plt.plot(x_coord, y_coord, 'ro')
|
||||
plt.axis([0, max_x + 100, max_y + 100, 0])
|
||||
plt.imshow(img)
|
||||
plt.show()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue