Skip to content

fix(grobid): match whitespace-only first-word differences, explain unwritable sync mismatches - #99

Merged
cboulanger merged 2 commits into
mainfrom
claude/project-thread-8ot2w2
Dec 3, 2026
Merged

cboulanger merged 2 commits into
mainfrom
claude/project-thread-8ot2w2

Conversation

@cboulanger

Copy link
Copy Markdown
Collaborator

Requested by Christian · project thread

Fixes #95.

Cause

"Reload feature file" only asks GROBID about the PDF's text layer. So a TEI change leaves the sync check only after "Write text corrections to PDF" has written it there. Some of the reported changes could not be written (fixed in core mpilhlt/pdf-tei-editor#1036). "( §" → "(§" is a whitespace-only change that the writer ignores by design, but the line-based check compared first words, so it was flagged forever and its fix dropped the "§".

Changes

  • Column 2 of a segmentation feature row is the line's second token (FeaturesVectorSegmentation.secondString, which repeats the first token for a line with one token). A line now also matches its row by the row's first two tokens joined, or by its own first two words joined. This is in layout.row_forms() and line_token(), and in rowForms() and firstTwoWords() in grobid-sync.js. /feature-tokens returns joined_tokens.
  • New GET /api/plugins/grobid/unwritable-lines returns the lines whose first word starts a change the text corrections cannot write (text_corrections.unwritable_lines(), via the core's derive_document_corrections()). With cores before plugin API 1.12 it returns unsupported. grobid-sync fetches it once per document and PDF, only when there are mismatches. It then appends to those diagnostics: "The change cannot be written to the PDF (reason), so reloading the feature file does not resolve it."
  • README and the training-data manual page are updated.

Tests

The Python tests (the core's plugin API 1.12 ones skip on older cores) and the JS tests (npm test) pass locally.


Generated by Claude Code

…writable sync mismatches

The sync check of segmentation documents now matches a line to its feature row also by the row's first two tokens joined (column 2 of the feature file) or by the line's first two words joined, since the editor's text corrections never write whitespace-only differences such as "( §" corrected to "(§". Mismatches on lines whose change the text corrections cannot write into the PDF say so, from the new /unwritable-lines route (needs plugin API 1.12, else unsupported).

Fixes #95

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S2kb9dTGETfyixjaXvSXRj
@cboulanger cboulanger self-assigned this Dec 3, 2026
…-8ot2w2

# Conflicts:
#	plugins/grobid/src/pte_plugin_grobid/extensions/grobid-sync.js
@cboulanger
cboulanger merged commit aec9db3 into main Dec 3, 2026
5 checks passed
@cboulanger
cboulanger deleted the claude/project-thread-8ot2w2 branch December 3, 2026 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Grobid: problems updating feature file

2 participants