diff options
| author | adamjanovsky | 2022-12-14 13:44:18 +0100 |
|---|---|---|
| committer | GitHub | 2022-12-14 13:44:18 +0100 |
| commit | 4e097b71f10718d446bd0eb0adc2fec58a865902 (patch) | |
| tree | 377ce1be12c4a6214a3351c24a81d15a36bcb02d /src | |
| parent | 9d1d44d04532609524fd862697179e179a6ea92c (diff) | |
| parent | 8af0d58b1fa763aa3fa923b08bacac1c6319fdc1 (diff) | |
| download | sec-certs-4e097b71f10718d446bd0eb0adc2fec58a865902.tar.gz sec-certs-4e097b71f10718d446bd0eb0adc2fec58a865902.tar.zst sec-certs-4e097b71f10718d446bd0eb0adc2fec58a865902.zip | |
Merge pull request #299 from crocs-muni/issue/298-OCR-processing-fails
Issue/298 ocr processing fails, delete draft release action, download spacy model during test pipeline
Diffstat (limited to 'src')
| -rw-r--r-- | src/sec_certs/utils/pdf.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/sec_certs/utils/pdf.py b/src/sec_certs/utils/pdf.py index 1d04a697..d97dff95 100644 --- a/src/sec_certs/utils/pdf.py +++ b/src/sec_certs/utils/pdf.py @@ -59,9 +59,13 @@ def ocr_pdf_file(pdf_path: Path) -> str: ) if tes.returncode != 0: raise ValueError(f"tesseract failed: {tes.returncode}") + contents = "" - txt_paths = list(glob.glob(str(tmppath / "image*.txt"))) - for txt_path in map(Path, sorted(txt_paths, key=lambda fname: int(fname[6:-4]))): + + txt_paths = [x for x in tmppath.iterdir() if x.is_file() and "image-" in x.stem and x.suffix == ".txt"] + txt_paths = sorted(txt_paths, key=lambda txt_path: int(txt_path.stem.split("-")[1])) + + for txt_path in txt_paths: with txt_path.open("r", encoding="utf-8") as f: contents += f.read() return contents |
