HowdenParser 3.0.0__tar.gz → 3.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {howdenparser-3.0.0 → howdenparser-3.1.1}/HowdenParser/parser.py +27 -3
- {howdenparser-3.0.0 → howdenparser-3.1.1}/PKG-INFO +1 -1
- {howdenparser-3.0.0 → howdenparser-3.1.1}/pyproject.toml +1 -1
- {howdenparser-3.0.0 → howdenparser-3.1.1}/HowdenParser/__init__.py +0 -0
- {howdenparser-3.0.0 → howdenparser-3.1.1}/HowdenParser/parameter/__init__.py +0 -0
- {howdenparser-3.0.0 → howdenparser-3.1.1}/HowdenParser/parameter/huggingface.py +0 -0
- {howdenparser-3.0.0 → howdenparser-3.1.1}/HowdenParser/parameter/llamaparser.py +0 -0
- {howdenparser-3.0.0 → howdenparser-3.1.1}/HowdenParser/parameter/mistralocr.py +0 -0
- {howdenparser-3.0.0 → howdenparser-3.1.1}/README.md +0 -0
|
@@ -14,6 +14,10 @@ logger = logging.getLogger(__name__)
|
|
|
14
14
|
class BaseParser(ABC):
|
|
15
15
|
_registry: dict[str, type["BaseParser"]] = {}
|
|
16
16
|
|
|
17
|
+
def __init__(self):
|
|
18
|
+
# Every instance gets a .name attribute
|
|
19
|
+
self.name = getattr(self.__class__, "_parser_name", self.__class__.__name__)
|
|
20
|
+
|
|
17
21
|
def __init_subclass__(cls, name: str | None = None, **kwargs):
|
|
18
22
|
"""Automatically register subclasses under a key."""
|
|
19
23
|
super().__init_subclass__(**kwargs)
|
|
@@ -57,6 +61,10 @@ class Parser(BaseParser):
|
|
|
57
61
|
provider_and_model: Literal["llamaparser:"],
|
|
58
62
|
result_type: str,
|
|
59
63
|
mode: bool,
|
|
64
|
+
preserve_layout_alignment_across_pages: bool,
|
|
65
|
+
merge_tables_across_pages_in_markdown: bool,
|
|
66
|
+
hide_footers: bool,
|
|
67
|
+
hide_headers: bool,
|
|
60
68
|
) -> "LlamaParser": ...
|
|
61
69
|
|
|
62
70
|
@overload
|
|
@@ -154,7 +162,7 @@ class Parser(BaseParser):
|
|
|
154
162
|
if missing:
|
|
155
163
|
example = ""
|
|
156
164
|
if provider == "llamaparser":
|
|
157
|
-
example = "Example: Parser('llamaparser:', result_type='md', mode=True)"
|
|
165
|
+
example = "Example: Parser('llamaparser:', result_type='md', mode=True, extract_tables=True)"
|
|
158
166
|
elif provider == "mistralocr":
|
|
159
167
|
example = "Example: Parser('mistralocr:ocr-large')"
|
|
160
168
|
elif provider == "huggingface":
|
|
@@ -227,11 +235,21 @@ class LangChainParser(BaseParser, name="langchain"):
|
|
|
227
235
|
|
|
228
236
|
|
|
229
237
|
class LlamaParser(BaseParser, name="llamaparser"):
|
|
230
|
-
def __init__(self, result_type: str,
|
|
238
|
+
def __init__(self, result_type: str,
|
|
239
|
+
mode: bool,
|
|
240
|
+
provider_and_model: str,
|
|
241
|
+
merge_tables_across_pages_in_markdown: bool,
|
|
242
|
+
preserve_layout_alignment_across_pages: bool,
|
|
243
|
+
hide_footers: bool,
|
|
244
|
+
hide_headers: bool) -> None:
|
|
231
245
|
logging.info("Initializing LlamaParser...")
|
|
232
246
|
self.result_type = result_type
|
|
233
247
|
self.mode = mode
|
|
234
248
|
self.provider_and_model = provider_and_model
|
|
249
|
+
self.merge_tables_across_pages_in_markdown = merge_tables_across_pages_in_markdown
|
|
250
|
+
self.preserve_layout_alignment_across_pages = preserve_layout_alignment_across_pages
|
|
251
|
+
self.hide_footers=hide_footers
|
|
252
|
+
self.hide_headers=hide_headers
|
|
235
253
|
|
|
236
254
|
from llama_parse import LlamaParse, ResultType
|
|
237
255
|
if result_type.lower() in ("md", "markdown"):
|
|
@@ -239,7 +257,13 @@ class LlamaParser(BaseParser, name="llamaparser"):
|
|
|
239
257
|
api_key = os.getenv("LLAMA-PARSER-API-TOKEN")
|
|
240
258
|
if not api_key:
|
|
241
259
|
raise EnvironmentError("Missing LLAMA-PARSER-API-TOKEN in .env file.")
|
|
242
|
-
self._parser = LlamaParse(api_key=api_key,
|
|
260
|
+
self._parser = LlamaParse(api_key=api_key,
|
|
261
|
+
result_type=result_type,
|
|
262
|
+
premium_mode=self.mode,
|
|
263
|
+
merge_tables_across_pages_in_markdown=self.merge_tables_across_pages_in_markdown,
|
|
264
|
+
preserve_layout_alignment_across_pages=self.preserve_layout_alignment_across_pages,
|
|
265
|
+
hide_footers=self.hide_footers,
|
|
266
|
+
hide_headers=self.hide_headers)
|
|
243
267
|
|
|
244
268
|
def parse(self, file_path: Path) -> str:
|
|
245
269
|
documents = self._parser.load_data(str(file_path))
|
|
@@ -14,7 +14,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
14
14
|
|
|
15
15
|
[tool.poetry]
|
|
16
16
|
name = "HowdenParser"
|
|
17
|
-
version = "3.
|
|
17
|
+
version = "3.1.1"
|
|
18
18
|
description = "A simple configuration manager with Pydantic and JSON export."
|
|
19
19
|
authors = [ "JesperThoftIllemannJ <jesper.jaeger@howdendanmark.dk>",]
|
|
20
20
|
readme = "README.md"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|