Update advanced docs

This commit is contained in:
Vinayak Mehta
2018-12-19 18:19:39 +05:30
parent 6301fee523
commit 48b2dce633
7 changed files with 34 additions and 32 deletions
+3 -3
View File
@@ -8,11 +8,11 @@ from ..utils import get_page_layout, get_text_objects
class BaseParser(object):
"""Defines a base parser.
"""
def _generate_layout(self, filename, extra_kwargs):
def _generate_layout(self, filename, layout_kwargs):
self.filename = filename
self.extra_kwargs = extra_kwargs
self.layout_kwargs = layout_kwargs
self.layout, self.dimensions = get_page_layout(
filename, **extra_kwargs)
filename, **layout_kwargs)
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
+3 -8
View File
@@ -70,17 +70,13 @@ class Lattice(BaseParser):
Number of times for erosion/dilation is applied.
For more information, refer `OpenCV's dilate <https://docs.opencv.org/2.4/modules/imgproc/doc/filtering.html#dilate>`_.
margins : tuple
PDFMiner char_margin, line_margin and word_margin.
For more information, refer `PDFMiner docs <https://euske.github.io/pdfminer/>`_.
"""
def __init__(self, table_areas=None, process_background=False,
line_size_scaling=15, copy_text=None, shift_text=['l', 't'],
split_text=False, flag_size=False, line_close_tol=2,
joint_close_tol=2, threshold_blocksize=15, threshold_constant=-2,
iterations=0, margins=(1.0, 0.5, 0.1), **kwargs):
iterations=0, **kwargs):
self.table_areas = table_areas
self.process_background = process_background
self.line_size_scaling = line_size_scaling
@@ -93,7 +89,6 @@ class Lattice(BaseParser):
self.threshold_blocksize = threshold_blocksize
self.threshold_constant = threshold_constant
self.iterations = iterations
self.char_margin, self.line_margin, self.word_margin = margins
@staticmethod
def _reduce_index(t, idx, shift_text):
@@ -348,8 +343,8 @@ class Lattice(BaseParser):
return table
def extract_tables(self, filename, suppress_stdout=False, extra_kwargs={}):
self._generate_layout(filename, extra_kwargs)
def extract_tables(self, filename, suppress_stdout=False, layout_kwargs={}):
self._generate_layout(filename, layout_kwargs)
if not suppress_stdout:
logger.info('Processing {}'.format(os.path.basename(self.rootname)))
+3 -9
View File
@@ -44,15 +44,10 @@ class Stream(BaseParser):
col_close_tol : int, optional (default: 0)
Tolerance parameter used to combine text horizontally,
to generate columns.
margins : tuple, optional (default: (1.0, 0.5, 0.1))
PDFMiner char_margin, line_margin and word_margin.
For more information, refer `PDFMiner docs <https://euske.github.io/pdfminer/>`_.
"""
def __init__(self, table_areas=None, columns=None, split_text=False,
flag_size=False, row_close_tol=2, col_close_tol=0,
margins=(1.0, 0.5, 0.1), **kwargs):
flag_size=False, row_close_tol=2, col_close_tol=0, **kwargs):
self.table_areas = table_areas
self.columns = columns
self._validate_columns()
@@ -60,7 +55,6 @@ class Stream(BaseParser):
self.flag_size = flag_size
self.row_close_tol = row_close_tol
self.col_close_tol = col_close_tol
self.char_margin, self.line_margin, self.word_margin = margins
@staticmethod
def _text_bbox(t_bbox):
@@ -388,8 +382,8 @@ class Stream(BaseParser):
return table
def extract_tables(self, filename, suppress_stdout=False, extra_kwargs={}):
self._generate_layout(filename, extra_kwargs)
def extract_tables(self, filename, suppress_stdout=False, layout_kwargs={}):
self._generate_layout(filename, layout_kwargs)
if not suppress_stdout:
logger.info('Processing {}'.format(os.path.basename(self.rootname)))