add doctor command, fix ISBN false positives, wire up CI
Some checks failed
tests / core (macos-latest, py3.11) (push) Has been cancelled
tests / core (macos-latest, py3.12) (push) Has been cancelled
tests / core (macos-latest, py3.13) (push) Has been cancelled
tests / core (ubuntu-latest, py3.11) (push) Has been cancelled
tests / core (ubuntu-latest, py3.12) (push) Has been cancelled
tests / core (ubuntu-latest, py3.13) (push) Has been cancelled
tests / doctor CLI smoke test (push) Has been cancelled

ISBN regex now requires an explicit prefix, so it stops matching
years, URLs, job IDs, and dilution ratios.

doctor checks the environment end to end: Python, Tesseract,
PaddleOCR, the PyTorch backend, table/figure detectors, scispaCy,
config, DB, output.

CI runs on 2 OS x 3 Python versions plus a doctor smoke job.
Also added a changelog
This commit is contained in:
2026-07-20 12:37:26 +02:00
parent a0211155fa
commit 39655fc35f
10 changed files with 547 additions and 4 deletions

66
tests/test_citations.py Normal file
View File

@@ -0,0 +1,66 @@
from __future__ import annotations
import pytest
from ocr_pipeline.citations.regex_extractor import Citation, RegexCitationExtractor
def _isbns(text: str) -> list[str]:
return [c.identifier for c in RegexCitationExtractor.extract(text) if c.type == "isbn"]
@pytest.mark.parametrize(
("text", "expected"),
[
("ISBN:978-0-306-40615-7", "ISBN:9780306406157"),
("ISBN 978-0-306-40615-7", "ISBN:9780306406157"),
("ISBN-13: 978-0-306-40615-7", "ISBN:9780306406157"),
("ISBN:0-306-40615-2", "ISBN:0306406152"),
("ISBN 0-306-40615-2", "ISBN:0306406152"),
("ISBN-10: 0-306-40615-2", "ISBN:0306406152"),
],
)
def test_recognises_real_isbns(text: str, expected: str) -> None:
assert expected in _isbns(text)
@pytest.mark.parametrize(
"text",
[
"2024-01-15",
"Due in 17 days, 2024",
"https://www.jobbnorge.no/jobs/300588",
"https://euraxess.ec.europa.eu/jobs/432300",
"Anti-BRCA1 (1:1000), Anti-beta-actin (1:5000)",
"30 ug per lane; gel 10% SDS-PAGE",
"Lane 1: WT control",
"PMID: 12345678",
"DOI: 10.1038/nature12345",
],
)
def test_no_isbn_false_positives(text: str) -> None:
assert _isbns(text) == []
def test_isbn_stripped_to_digits() -> None:
identifiers = _isbns("ISBN: 978-0-306-40615-7")
assert identifiers == ["ISBN:9780306406157"]
def test_doi_still_works() -> None:
dois = [
c for c in RegexCitationExtractor.extract("See DOI: 10.1038/nature12345") if c.type == "doi"
]
assert len(dois) == 1
assert dois[0].identifier == "10.1038/nature12345"
def test_pmid_still_works() -> None:
pmids = [c for c in RegexCitationExtractor.extract("PMID: 12345678") if c.type == "pmid"]
assert len(pmids) == 1
assert pmids[0].identifier == "PMID:12345678"
def test_citation_dataclass_fields() -> None:
c = Citation(raw="x", type="doi", identifier="y", confidence=0.5)
assert c.context == ""