Skip to content

A fast, helpful, and open-source document parser

fix: add updated values to python config object

Logan Markewicha1e4f2ff69c5
diff --git a/crates/liteparse-python/src/lib.rs b/crates/liteparse-python/src/lib.rs
index f773b6d..e90b3a1 100644
--- a/crates/liteparse-python/src/lib.rs
+++ b/crates/liteparse-python/src/lib.rs
@@ -373,6 +373,22 @@ struct PyLiteParseConfig {
quiet: bool,
#[pyo3(get)]
num_workers: usize,
+ #[pyo3(get)]
+ image_mode: String,
+ #[pyo3(get)]
+ extract_links: bool,
+ #[pyo3(get)]
+ ocr_failure_fatal: bool,
+ #[pyo3(get)]
+ ocr_hedge_delays_ms: Vec<u64>,
+ #[pyo3(get)]
+ emit_word_boxes: bool,
+ #[pyo3(get)]
+ crop_box: Option<(f32, f32, f32, f32)>,
+ #[pyo3(get)]
+ skip_diagonal_text: bool,
+ #[pyo3(get)]
+ include_complexity: bool,
}
#[pymethods]
@@ -409,6 +425,21 @@ impl PyLiteParseConfig {
password: cfg.password.clone(),
quiet: cfg.quiet,
num_workers: cfg.num_workers,
+ image_mode: match cfg.image_mode {
+ ImageMode::Off => "off".to_string(),
+ ImageMode::Placeholder => "placeholder".to_string(),
+ ImageMode::Embed => "embed".to_string(),
+ },
+ extract_links: cfg.extract_links,
+ ocr_failure_fatal: cfg.ocr_failure_fatal,
+ ocr_hedge_delays_ms: cfg.ocr_hedge_delays_ms.clone(),
+ emit_word_boxes: cfg.emit_word_boxes,
+ crop_box: cfg
+ .crop_box
+ .as_ref()
+ .map(|c| (c.top, c.right, c.bottom, c.left)),
+ skip_diagonal_text: cfg.skip_diagonal_text,
+ include_complexity: cfg.include_complexity,
}
}
}
diff --git a/packages/python/liteparse/parser.py b/packages/python/liteparse/parser.py
index f3efe97..c776798 100644
--- a/packages/python/liteparse/parser.py
+++ b/packages/python/liteparse/parser.py
@@ -361,6 +361,14 @@ class LiteParse:
password=cfg.password,
quiet=cfg.quiet,
num_workers=cfg.num_workers,
+ image_mode=cfg.image_mode,
+ extract_links=cfg.extract_links,
+ ocr_failure_fatal=cfg.ocr_failure_fatal,
+ ocr_hedge_delays_ms=list(cfg.ocr_hedge_delays_ms),
+ emit_word_boxes=cfg.emit_word_boxes,
+ crop_box=cfg.crop_box,
+ skip_diagonal_text=cfg.skip_diagonal_text,
+ include_complexity=cfg.include_complexity,
)
def __repr__(self) -> str:
diff --git a/packages/python/liteparse/types.py b/packages/python/liteparse/types.py
index a080964..e12dfd0 100644
--- a/packages/python/liteparse/types.py
+++ b/packages/python/liteparse/types.py
@@ -3,7 +3,7 @@
from __future__ import annotations
from dataclasses import dataclass, field
-from typing import Dict, Iterator, List, Optional
+from typing import Dict, Iterator, List, Optional, Tuple
@dataclass
@@ -125,6 +125,16 @@ class LiteParseConfig:
password: Optional[str]
quiet: bool
num_workers: int
+ image_mode: str
+ extract_links: bool
+ ocr_failure_fatal: bool
+ ocr_hedge_delays_ms: List[int]
+ emit_word_boxes: bool
+ #: ``(top, right, bottom, left)`` crop fractions, or ``None`` when the whole
+ #: page is kept.
+ crop_box: Optional[Tuple[float, float, float, float]]
+ skip_diagonal_text: bool
+ include_complexity: bool
class ParseError(Exception):