Skip to content

Commit

Permalink
TLDR-474 remove insert_table parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
NastyBoget committed Sep 28, 2023
1 parent d752ad2 commit 78d8f6a
Show file tree
Hide file tree
Showing 13 changed files with 1 addition and 877 deletions.
3 changes: 0 additions & 3 deletions dedoc/api/api_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class QueryParameters(BaseModel):
return_base64: Optional[str]
attachments_dir: Optional[str]

insert_table: Optional[str]
need_pdf_table_analysis: Optional[str]
table_type: Optional[str]
orient_analysis_cells: Optional[str]
Expand Down Expand Up @@ -48,7 +47,6 @@ def __init__(self,
attachments_dir: Optional[str] = Body(description="path to the directory where to save files' attachments", default=None), # noqa

# tables handling
insert_table: Optional[str] = Body(description="Insert table into the result tree's content or not. Default: 'false'", default=None), # noqa
need_pdf_table_analysis: Optional[str] = Body(description="include a table analysis into pdfs. Default: 'true'", default=None), # noqa
table_type: Optional[str] = Body(description="a pipeline mode for a table recognition. Default: ''", default=None), # noqa
orient_analysis_cells: Optional[str] = Body(description="a table recognition option enables analysis of rotated cells in table headers. Default: 'false'", default=None), # noqa
Expand Down Expand Up @@ -83,7 +81,6 @@ def __init__(self,
self.return_base64: str = return_base64 or "false"
self.attachments_dir: str = attachments_dir

self.insert_table: str = insert_table or "false"
self.need_pdf_table_analysis: str = need_pdf_table_analysis or "true"
self.table_type: str = table_type or ""
self.orient_analysis_cells: str = orient_analysis_cells or "false"
Expand Down
1 change: 0 additions & 1 deletion dedoc/api/static/html_eng/form_input.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ <h2>Structure Document Recognition</h2>
</select>
</label> return_format
</p>
<p><label><input type="checkbox" name="insert_table" value="true"> insert_table</label></p>
<p><label><input type="checkbox" name="handle_invisible_table" value="true"> handle_invisible_table</label></p>
<p>pages <input name="pages" type="text" size="8" value=":"> </p>

Expand Down
2 changes: 0 additions & 2 deletions dedoc/api/static/html_eng/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ <h2>How to use</h2>
<ol>
<li><strong>language</strong>: string - document recognition language. The default value is "rus+eng". Available values: "rus+eng", "rus", "eng".</li>
<li><strong>with_attachments</strong>: boolean - option including analysis of attached files. The option is False by default. Available values: True, False.</li>
<li><strong>insert_table</strong>: boolean - this option enables embedding the table in the document tree.
The option is False by default. Available values: True, False.</li>
<li><strong>return_format</strong>: str - an option to return the response in pretty_json, html, json or tree form.
The default value is json. Use the pretty_json, tree and html format for debug only.<br>
Warning: html-format is used only for viewing the recognition result (in a readable form).
Expand Down
3 changes: 0 additions & 3 deletions dedoc/api/static/html_rus/form_input.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ <h2>Распознавание структуры документа</h2>
</label> with_attachments</p>
<p>
<p>
<label>
<input type="checkbox" name="insert_table" value=true>
</label> insert_table </p>
<p>
<label>
<select name="document_type">
Expand Down
2 changes: 0 additions & 2 deletions dedoc/api/static/html_rus/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ <h2>Как использовать</h2>
<ol>
<li><strong>language</strong>: str - язык рапознавания документа. По-умолчанию установлено значение "rus+eng".
Доступные значения: "rus+eng", "rus", "eng".</li>
<li><strong>insert_table</strong>: boolean - опция включает встраивание таблицы в документное дерево.
По-умолчанию установлено значение False. Доступные значения True, False.</li>
<li><strong>with_attachments</strong>: boolean - опция включающая анализ вложенных файлов. По-умолчанию установлено
значение False. Доступные значения True, False.</li>
<li><strong>return_format</strong>: str - опция для возврата ответа в html-виде, в виде дерева или в виде json.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from dedoc.data_structures.parsed_document import ParsedDocument
from dedoc.data_structures.unstructured_document import UnstructuredDocument
from dedoc.structure_constructors.abstract_structure_constructor import AbstractStructureConstructor
from dedoc.structure_constructors.table_patcher import TablePatcher


class StructureConstructorComposition(AbstractStructureConstructor):
Expand All @@ -20,19 +19,13 @@ def __init__(self, constructors: Dict[str, AbstractStructureConstructor], defaul
"""
self.constructors = constructors
self.default_constructor = default_constructor
self.table_patcher = TablePatcher()

def structure_document(self, document: UnstructuredDocument, structure_type: Optional[str] = None, parameters: Optional[dict] = None) -> ParsedDocument:
"""
Construct the result document structure according to the `structure_type` parameter.
If `structure_type` is empty string or None the default constructor will be used.
To get the information about the parameters look at the documentation of :class:`~dedoc.structure_constructors.AbstractStructureConstructor`.
"""
parameters = {} if parameters is None else parameters

if parameters.get("insert_table", "False").lower() == "true":
document = self.table_patcher.insert_table(document=document)

if structure_type in self.constructors:
return self.constructors[structure_type].structure_document(document)

Expand Down
80 changes: 0 additions & 80 deletions dedoc/structure_constructors/table_patcher.py

This file was deleted.

13 changes: 0 additions & 13 deletions docs/source/_static/code_examples/dedoc_return_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,6 @@ def with_parsed_attachments_example() -> dict:
return json.loads(result)


def with_inserted_table_example() -> dict:
with open(filename, "rb") as file:
files = {"file": (filename, file)}
r = requests.post("http://localhost:1231/upload", files=files, data=dict(insert_table="true"))
result = r.content.decode("utf-8")

assert r.status_code == 200
return json.loads(result)


if __name__ == "__main__":
with open("../json_format_examples/basic_example.json", "w") as f:
json.dump(basic_example(), f, indent=2, ensure_ascii=False)
Expand All @@ -80,6 +70,3 @@ def with_inserted_table_example() -> dict:

with open("../json_format_examples/with_parsed_attachments.json", "w") as f:
json.dump(with_parsed_attachments_example(), f, indent=2, ensure_ascii=False)

with open("../json_format_examples/with_inserted_table.json", "w") as f:
json.dump(with_inserted_table_example(), f, indent=2, ensure_ascii=False)
Loading

0 comments on commit 78d8f6a

Please sign in to comment.