|
5 | 5 |
|
6 | 6 |
|
7 | 7 | class QueryParameters(BaseModel): |
8 | | - language: Optional[str] |
| 8 | + document_type: Optional[str] |
| 9 | + structure_type: Optional[str] |
| 10 | + return_format: Optional[str] |
| 11 | + |
9 | 12 | with_attachments: Optional[str] |
| 13 | + need_content_analysis: Optional[str] |
| 14 | + recursion_deep_attachments: Optional[str] |
| 15 | + return_base64: Optional[str] |
| 16 | + |
10 | 17 | insert_table: Optional[str] |
11 | | - return_format: Optional[str] |
12 | | - structure_type: Optional[str] |
13 | | - delimiter: Optional[str] |
14 | | - encoding: Optional[str] |
15 | | - document_type: Optional[str] |
16 | | - pdf_with_text_layer: Optional[str] |
17 | | - pages: Optional[str] |
| 18 | + need_pdf_table_analysis: Optional[str] |
| 19 | + table_type: Optional[str] |
18 | 20 | orient_analysis_cells: Optional[str] |
19 | 21 | orient_cell_angle: Optional[str] |
| 22 | + |
| 23 | + pdf_with_text_layer: Optional[str] |
| 24 | + language: Optional[str] |
| 25 | + pages: Optional[str] |
20 | 26 | is_one_column_document: Optional[str] |
21 | 27 | document_orientation: Optional[str] |
22 | | - html_fields: Optional[str] |
23 | | - cloud_bucket: Optional[str] |
24 | 28 | need_header_footer_analysis: Optional[str] |
25 | 29 | need_binarization: Optional[str] |
26 | | - need_pdf_table_analysis: Optional[str] |
| 30 | + |
| 31 | + delimiter: Optional[str] |
| 32 | + encoding: Optional[str] |
| 33 | + html_fields: Optional[str] |
27 | 34 | handle_invisible_table: Optional[str] |
28 | | - return_base64: Optional[str] |
29 | | - archive_as_single_file: Optional[str] |
30 | | - upload_attachments_into_cloud: Optional[str] |
31 | | - need_content_analysis: Optional[str] |
32 | | - recursion_deep_attachments: Optional[str] |
33 | | - table_type: Optional[str] |
34 | 35 |
|
35 | 36 | def __init__(self, |
36 | | - language: Optional[str] = Body(description="a recognition language. Default: 'rus+eng'", enum=["rus+eng", "rus", "eng"], default=None), |
| 37 | + # type of document structure parsing |
| 38 | + document_type: Optional[str] = Body(description="a document type. Default: ''", enum=["", "law", "tz", "diploma"], default=None), |
| 39 | + structure_type: Optional[str] = Body(description="output structure type (linear or tree). Default: 'tree'", enum=["linear", "tree"], default=None), |
| 40 | + return_format: Optional[str] = Body(description="an option for returning a response in html form, json, pretty_json or tree. Assume that one should use json in all cases, all other formats are used for debug porpoises only. Default: 'json'", default=None), |
| 41 | + |
| 42 | + # attachments handling |
37 | 43 | with_attachments: Optional[str] = Body(description="an option to enable the analysis of attached files. Default: 'false'", default=None), |
| 44 | + need_content_analysis: Optional[str] = Body(description="turn on if you need parse the contents of the document attachments. Default: 'false'", default=None), |
| 45 | + recursion_deep_attachments: Optional[str] = Body(description="the depth on which nested attachments will be parsed if need_content_analysis=true. Default: '10'", default=None), |
| 46 | + return_base64: Optional[str] = Body(description="returns images in base64 format. Default: 'false'", default=None), |
| 47 | + |
| 48 | + # tables handling |
38 | 49 | insert_table: Optional[str] = Body(description="Insert table into the result tree's content or not. Default: 'false'", default=None), |
39 | | - return_format: Optional[str] = Body(description="an option for returning a response in html form, json, pretty_json or tree. Assume that one should use json in all cases, all other formats are used for debug porpoises only. Default: 'json'", default=None), |
40 | | - structure_type: Optional[str] = Body(description="output structure type (linear or tree). Default: 'tree'", enum=["linear", "tree"], default=None), |
41 | | - delimiter: Optional[str] = Body(description="a column separator for csv-files", default=None), |
42 | | - encoding: Optional[str] = Body(description="a document encoding", default=None), |
43 | | - document_type: Optional[str] = Body(description="a document type. Default: ''", enum=["", "law", "tz", "diploma", "article", "slide"], default=None), |
44 | | - pdf_with_text_layer: Optional[str] = Body(description="an option to extract text from a text layer to PDF or using OCR methods for image-documents. Default: 'auto_tabby'", enum=["true", "false", "auto", "auto_tabby", "tabby"], default=None), |
45 | | - pages: Optional[str] = Body(description="an option to limit page numbers in pdf, archives with images. left:right, read pages from left to right. Default: ':'", default=None), |
| 50 | + need_pdf_table_analysis: Optional[str] = Body(description="include a table analysis into pdfs. Default: 'true'", default=None), |
| 51 | + table_type: Optional[str] = Body(description="a pipeline mode for a table recognition. Default: ''", default=None), |
46 | 52 | orient_analysis_cells: Optional[str] = Body(description="a table recognition option enables analysis of rotated cells in table headers. Default: 'false'", default=None), |
47 | 53 | orient_cell_angle: Optional[str] = Body(description="an option to set orientation of cells in table headers. \"270\" - cells are rotated 90 degrees clockwise, \"90\" - cells are rotated 90 degrees counterclockwise (or 270 clockwise)", default=None), |
| 54 | + |
| 55 | + # pdf handling |
| 56 | + pdf_with_text_layer: Optional[str] = Body(description="an option to extract text from a text layer to PDF or using OCR methods for image-documents. Default: 'auto_tabby'", enum=["true", "false", "auto", "auto_tabby", "tabby"], default=None), |
| 57 | + language: Optional[str] = Body(description="a recognition language. Default: 'rus+eng'", enum=["rus+eng", "rus", "eng"], default=None), |
| 58 | + pages: Optional[str] = Body(description="an option to limit page numbers in pdf, archives with images. left:right, read pages from left to right. Default: ':'", default=None), |
48 | 59 | is_one_column_document: Optional[str] = Body(description="an option to set one or multiple column document. \"auto\" - system predict number of columns in document pages, \"true\" - is one column documents, \"false\" - is multiple column documents. Default: 'auto'", default=None), |
49 | | - document_orientation: Optional[str] = Body(description="an option to set vertical orientation of the document without using an orientation classifier \"auto\" - system predict angle (0, 90, 180, 370) and rotate document, \"no_change\" - do not predict orientation. Default: 'auto'", enum=["auto", "no_change"], default=None), |
50 | | - html_fields: Optional[str] = Body(description="a list of fields for JSON documents to be parsed as HTML documents. It is written as a json string of a list, where each list item is a list of keys to get the field. Default: ''", default=None), |
51 | | - cloud_bucket: Optional[str] = Body(description="a path (bucket) in the cloud storage mime. Default: ''", default=None), |
| 60 | + document_orientation: Optional[str] = Body(description="an option to set vertical orientation of the document without using an orientation classifier \"auto\" - system predict angle (0, 90, 180, 270) and rotate document, \"no_change\" - do not predict orientation. Default: 'auto'", enum=["auto", "no_change"], default=None), |
52 | 61 | need_header_footer_analysis: Optional[str] = Body(description="include header-footer analysis into pdf with text layer. Default: 'false'", default=None), |
53 | 62 | need_binarization: Optional[str] = Body(description="include an adaptive binarization into pdf without a text layer. Default: 'false'", default=None), |
54 | | - need_pdf_table_analysis: Optional[str] = Body(description="include a table analysis into pdfs. Default: 'true'", default=None), |
| 63 | + |
| 64 | + # other formats handling |
| 65 | + delimiter: Optional[str] = Body(description="a column separator for csv-files", default=None), |
| 66 | + encoding: Optional[str] = Body(description="a document encoding", default=None), |
| 67 | + html_fields: Optional[str] = Body(description="a list of fields for JSON documents to be parsed as HTML documents. It is written as a json string of a list, where each list item is a list of keys to get the field. Default: ''", default=None), |
55 | 68 | handle_invisible_table: Optional[str] = Body(description="handle table without visible borders as tables in html. Default: 'false'", default=None), |
56 | | - return_base64: Optional[str] = Body(description="returns images in base64 format. Default: 'false'", default=None), |
57 | | - archive_as_single_file: Optional[str] = Body(description="additional parameters for the archive reader. Default: 'true'", default=None), |
58 | | - upload_attachments_into_cloud: Optional[str] = Body(description="turn on if you need upload attachments into a cloud. Turn on if with_attachments=True and \"cloud_bucket\" not empty. Default: 'false'", default=None), |
59 | | - need_content_analysis: Optional[str] = Body(description="turn on if you need parse the contents of the document attachments. Default: 'false'", default=None), |
60 | | - recursion_deep_attachments: Optional[str] = Body(description="the depth on which nested attachments will be parsed if need_content_analysis=true. Default: '10'", default=None), |
61 | | - table_type: Optional[str] = Body(description="a pipeline mode for a table recognition. Default: ''", default=None), |
| 69 | + |
| 70 | + |
62 | 71 | **data: Any) -> None: |
63 | 72 |
|
64 | 73 | super().__init__(**data) |
65 | | - self.language: str = language or "rus+eng" |
| 74 | + self.document_type: str = document_type or "" |
| 75 | + self.structure_type: str = structure_type or 'tree' |
| 76 | + self.return_format: str = return_format or 'json' |
| 77 | + |
66 | 78 | self.with_attachments: str = with_attachments or 'false' |
| 79 | + self.need_content_analysis: str = need_content_analysis or 'false' |
| 80 | + self.recursion_deep_attachments: str = recursion_deep_attachments or '10' |
| 81 | + self.return_base64: str = return_base64 or 'false' |
| 82 | + |
67 | 83 | self.insert_table: str = insert_table or 'false' |
68 | | - self.return_format: str = return_format or 'json' |
69 | | - self.structure_type: str = structure_type or 'tree' |
70 | | - self.delimiter: str = delimiter |
71 | | - self.encoding: str = encoding |
72 | | - self.document_type: str = document_type or "" |
73 | | - self.pdf_with_text_layer: str = pdf_with_text_layer or 'auto_tabby' |
74 | | - self.pages: str = pages or ':' |
| 84 | + self.need_pdf_table_analysis: str = need_pdf_table_analysis or 'true' |
| 85 | + self.table_type: str = table_type or '' |
75 | 86 | self.orient_analysis_cells: str = orient_analysis_cells or 'false' |
76 | 87 | self.orient_cell_angle: str = orient_cell_angle or "90" |
| 88 | + |
| 89 | + self.pdf_with_text_layer: str = pdf_with_text_layer or 'auto_tabby' |
| 90 | + self.language: str = language or "rus+eng" |
| 91 | + self.pages: str = pages or ':' |
77 | 92 | self.is_one_column_document: str = is_one_column_document or 'auto' |
78 | 93 | self.document_orientation: str = document_orientation or "auto" |
79 | | - self.html_fields: str = html_fields or '' |
80 | | - self.cloud_bucket: str = cloud_bucket or '' |
81 | 94 | self.need_header_footer_analysis: str = need_header_footer_analysis or 'false' |
82 | 95 | self.need_binarization: str = need_binarization or 'false' |
83 | | - self.need_pdf_table_analysis: str = need_pdf_table_analysis or 'true' |
| 96 | + |
| 97 | + self.delimiter: str = delimiter |
| 98 | + self.encoding: str = encoding |
| 99 | + self.html_fields: str = html_fields or '' |
84 | 100 | self.handle_invisible_table: str = handle_invisible_table or 'false' |
85 | | - self.return_base64: str = return_base64 or 'false' |
86 | | - self.archive_as_single_file: str = archive_as_single_file or 'true' |
87 | | - self.upload_attachments_into_cloud: str = upload_attachments_into_cloud or 'false' |
88 | | - self.need_content_analysis: str = need_content_analysis or 'false' |
89 | | - self.recursion_deep_attachments: str = recursion_deep_attachments or '10' |
90 | | - self.table_type: str = table_type or '' |
|
0 commit comments