HowdenParser 3.0.0__tar.gz → 3.1.0__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.
@@ -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,8 @@ 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
60
66
  ) -> "LlamaParser": ...
61
67
 
62
68
  @overload
@@ -154,7 +160,7 @@ class Parser(BaseParser):
154
160
  if missing:
155
161
  example = ""
156
162
  if provider == "llamaparser":
157
- example = "Example: Parser('llamaparser:', result_type='md', mode=True)"
163
+ example = "Example: Parser('llamaparser:', result_type='md', mode=True, extract_tables=True)"
158
164
  elif provider == "mistralocr":
159
165
  example = "Example: Parser('mistralocr:ocr-large')"
160
166
  elif provider == "huggingface":
@@ -227,11 +233,17 @@ class LangChainParser(BaseParser, name="langchain"):
227
233
 
228
234
 
229
235
  class LlamaParser(BaseParser, name="llamaparser"):
230
- def __init__(self, result_type: str, mode: bool, provider_and_model) -> None:
236
+ def __init__(self, result_type: str,
237
+ mode: bool,
238
+ provider_and_model: str,
239
+ merge_tables_across_pages_in_markdown: bool,
240
+ preserve_layout_alignment_across_pages: bool) -> None:
231
241
  logging.info("Initializing LlamaParser...")
232
242
  self.result_type = result_type
233
243
  self.mode = mode
234
244
  self.provider_and_model = provider_and_model
245
+ self.merge_tables_across_pages_in_markdown = merge_tables_across_pages_in_markdown
246
+ self.preserve_layout_alignment_across_pages = preserve_layout_alignment_across_pages
235
247
 
236
248
  from llama_parse import LlamaParse, ResultType
237
249
  if result_type.lower() in ("md", "markdown"):
@@ -239,7 +251,11 @@ class LlamaParser(BaseParser, name="llamaparser"):
239
251
  api_key = os.getenv("LLAMA-PARSER-API-TOKEN")
240
252
  if not api_key:
241
253
  raise EnvironmentError("Missing LLAMA-PARSER-API-TOKEN in .env file.")
242
- self._parser = LlamaParse(api_key=api_key, result_type=result_type, premium_mode=self.mode)
254
+ self._parser = LlamaParse(api_key=api_key,
255
+ result_type=result_type,
256
+ premium_mode=self.mode,
257
+ merge_tables_across_pages_in_markdown=self.merge_tables_across_pages_in_markdown,
258
+ preserve_layout_alignment_across_pages=self.preserve_layout_alignment_across_pages)
243
259
 
244
260
  def parse(self, file_path: Path) -> str:
245
261
  documents = self._parser.load_data(str(file_path))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: HowdenParser
3
- Version: 3.0.0
3
+ Version: 3.1.0
4
4
  Summary: A simple configuration manager with Pydantic and JSON export.
5
5
  License: MIT
6
6
  Keywords: config,configuration,pydantic,json
@@ -14,7 +14,7 @@ build-backend = "poetry.core.masonry.api"
14
14
 
15
15
  [tool.poetry]
16
16
  name = "HowdenParser"
17
- version = "3.0.0"
17
+ version = "3.1.0"
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