src.dackar.RCA.doc_parsers.pdfParser¶
Attributes¶
Functions¶
|
Infer doc_type from filename first, then first ~500 chars of text. |
|
|
|
Lightweight extraction-quality heuristic for Stage 1 provenance. |
Return filename without extension from a path. |
|
|
|
|
Marker images are commonly saved with names like '_page_12_Picture_3.jpeg'. |
|
Convert Marker-produced Markdown tables into a normalized JSON structure: |
|
Extract tables using pdfplumber and normalize to JSON objects. |
|
Parse a PDF file into: |
Module Contents¶
- src.dackar.RCA.doc_parsers.pdfParser.infer_doc_type(filename, early_text='')[source]¶
Infer doc_type from filename first, then first ~500 chars of text. Returns one of: CR | WO | SOP | ECA | OTHER
- Parameters:
filename (str)
early_text (str)
- Return type:
str
- src.dackar.RCA.doc_parsers.pdfParser._clean_table_cell(x)[source]¶
- Parameters:
x (Any)
- Return type:
str
- src.dackar.RCA.doc_parsers.pdfParser._clean_table_obj(t)[source]¶
- Parameters:
t (Dict[str, Any])
- Return type:
Dict[str, Any]
- src.dackar.RCA.doc_parsers.pdfParser._estimate_text_extraction_quality(markdown_text, page_count)[source]¶
Lightweight extraction-quality heuristic for Stage 1 provenance.
- Parameters:
markdown_text (str)
page_count (Optional[int])
- Return type:
Dict[str, Any]
- src.dackar.RCA.doc_parsers.pdfParser.get_file_name_no_extension(path)[source]¶
Return filename without extension from a path.
- Parameters:
path (str)
- Return type:
str
- src.dackar.RCA.doc_parsers.pdfParser._ensure_dir(path)[source]¶
- Parameters:
path (str)
- Return type:
None
- src.dackar.RCA.doc_parsers.pdfParser._parse_marker_image_key(image_key)[source]¶
Marker images are commonly saved with names like ‘_page_12_Picture_3.jpeg’. Extract page/index if present; otherwise return None values.
- Parameters:
image_key (str)
- Return type:
Dict[str, Any]
- src.dackar.RCA.doc_parsers.pdfParser._normalize_table_markdown_to_json(md_text)[source]¶
Convert Marker-produced Markdown tables into a normalized JSON structure: [
{ “columns”: […], “rows”: [[…], …], “caption”: None, “page”: None }
] Assumes tables are separated in MD by blank lines and follow pipe ‘|’ syntax.
- Parameters:
md_text (str)
- Return type:
List[Dict[str, Any]]
- src.dackar.RCA.doc_parsers.pdfParser._tables_from_pdfplumber(filename)[source]¶
Extract tables using pdfplumber and normalize to JSON objects.
- Parameters:
filename (str)
- Return type:
List[Dict[str, Any]]
- src.dackar.RCA.doc_parsers.pdfParser.pdfParser(home_folder=None, red_filepath=None, destination_folder=None, text2markdown='marker', tableParser='marker', classification='internal', ingest_id=None, source_path=None)[source]¶
- Parse a PDF file into:
text markdown
figures (images)
tables (normalized JSON)
- Emit:
document_index.json (paths + metadata)
text.md
tables.json
figures/*.jpeg
metadata.json (Marker-render metadata when available)
- Returns:
index dict mirroring document_index.json
- Parameters:
home_folder (Optional[str]) – Base folder for relative path red_filepath.
red_filepath (Optional[str]) – File path relative to home_folder (or absolute if home_folder is None).
destination_folder (Optional[str]) – Root destination for parsed outputs.
text2markdown (str) – Only ‘marker’ supported for now.
tableParser (str) – ‘marker’ or ‘pdfplumber’.
classification (str) – Data classification tag.
ingest_id (Optional[str])
source_path (Optional[str])
- Returns:
Document index with artifact paths and rich metadata.
- Return type:
Dict[str, Any]
- Raises:
FileNotFoundError – If input or destination paths are invalid.
ValueError – For unsupported options.