add doctor command, fix ISBN false positives, wire up CI
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
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:
1 parent
a0211155fa
commit
39655fc35f
10 files changed
+547
-4
No files matched your search
Binary file not shown.
@@ -34,7 +34,13 @@ class RegexCitationExtractor:
|
||||
re.IGNORECASE,
|
||||
)
|
||||
ISBN_PATTERN = re.compile(
|
||||
r"\b(?:ISBN[-\s]*(?:13|10)?[-\s]*)?(?:97[89][-\s]*)?\d{1,5}[-\s]*\d{1,7}[-\s]*\d{1,7}[-\s]*[\dX]\b",
|
||||
r"(?:"
|
||||
# 13-digit: ISBN[-: ]*(13)?[-: ]* 978|979 [-: ]* group groups group check
|
||||
r"(?P<isbn13>\bISBN[-:\s]*(?:13[-:\s]*)?97[89][-:\s]*\d{1,5}[-:\s]*\d{1,7}[-:\s]*\d{1,7}[-:\s]*[\dX]\b)"
|
||||
r"|"
|
||||
# 10-digit: ISBN[-: ]*(10)?[-: ]* group - group - check
|
||||
r"(?P<isbn10>\bISBN[-:\s]*(?:10[-:\s]*)?\d{1,5}[-:\s]*\d{1,7}[-:\s]*\d{1,7}[-:\s]*[\dX]\b)"
|
||||
r")",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
|
||||
@@ -84,12 +90,15 @@ class RegexCitationExtractor:
|
||||
for match in cls.ISBN_PATTERN.finditer(text):
|
||||
ctx_start = max(0, match.start() - 80)
|
||||
ctx_end = min(len(text), match.end() + 80)
|
||||
isbn = re.sub(r"[-\s]", "", match.group())
|
||||
raw = match.group()
|
||||
# Drop the leading "ISBN" prefix and any separators to get the digits/check.
|
||||
isbn_digits = re.sub(r"^(?:ISBN[-:\s]*(?:1[03])?[-:\s]*)", "", raw, flags=re.IGNORECASE)
|
||||
isbn_digits = re.sub(r"[-:\s]", "", isbn_digits)
|
||||
citations.append(
|
||||
Citation(
|
||||
raw=match.group(),
|
||||
raw=raw,
|
||||
type="isbn",
|
||||
identifier=f"ISBN:{isbn}",
|
||||
identifier=f"ISBN:{isbn_digits}",
|
||||
confidence=0.7,
|
||||
context=text[ctx_start:ctx_end].strip(),
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user