Skip to content

gotex-worddiff: which words moved, read through the extractor the score uses - #773

Merged
tannevaled merged 2 commits into
mainfrom
worddiff
Nov 13, 2026
Merged

tannevaled merged 2 commits into
mainfrom
worddiff

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

gotex-worddiff: which words moved, read through the extractor the score uses

gotex-refdiff says a paper fell 0.1 points of word recall. It does not say
WHICH words, so there is no way to tell a regression from an improvement the
metric mis-counts — #716's subject, and what #772 ran into head-on.

gotex-worddiff reports the multiset difference between two of OUR PDFs: the
words one holds that the other lacks, and the reverse. No reference — measuring
against the oracle is gotex-refdiff's job and this does not duplicate it.
Exit 0 same words, 1 different, 2 an error.

$ gotex-worddiff base.pdf head.pdf
only in base.pdf (36)
  acterized
  char-
  exponen-
  …
only in head.pdf (37)
  characterized
  exponential
  …

⛔⛔ Its first act was to catch its own author, and that is why the extractor is shared

The scratch probe this replaces read the PDFs with pdfops text. It reported
that a revtex affiliation block had set as CenterforTheoretical,
QiluNormalUniversity — words with no spaces between them — and that #772 had
repaired them. I published that on #772 and on #716 before checking it.

Reading the same two files through poppler's pdftotext, which is what
gotex-refdiff SCORES with, there is no such difference. The engine's own line
dump shows the spaces present in both files at identical coordinates:

base   y=120.19  x0=72.56  x1=561.63  | …; Center for Theoretical Physics of Complex …
head   y=120.19  x0=72.56  x1=561.63  | …; Center for Theoretical Physics of Complex …

The finding was two extractors disagreeing, dressed as an engine defect. Both
comments are corrected.

So the extraction itself — which binary, how it is found on PATH or through
pkgx, and the poppler project pin that stops pkgx pdftotext failing with
MultipleProjects — moves into internal/pdftext, and gotex-refdiff is
rewired onto it. One extractor, so the diff and the score cannot disagree about
what a word is.

⚠ WHAT DOES NOT MOVE: extraction, extractText and the genuine-empty versus
tool-error distinction stay in gotex-refdiff. Those are its scoring
semantics, not extraction, and dragging them into a shared package would make
the next tool inherit decisions it has no use for.

Tested

the shapes a line-breaking change makes a word split across a hyphen on one side and whole on the other, a fused token
a word both files hold not a difference; the same words reordered exit 0
it is a MULTISET three occurrences against two IS a difference
⛔ a failed extraction an error, never an empty page — otherwise a missing poppler reports every word of the other file as a difference, a maximal and confident meaningless answer
an absent or zero-byte file likewise an error
internal/pdftext the poppler pin, a tool found on PATH, and a missing tool that must error rather than return no text

The repository's own gate caught the missing .gitignore row
(TestEveryCommandIsIgnoredAtTheRoot). README has a row for the new command.

Refs #716, #772.

🤖 Generated with Claude Code

tannevaled and others added 2 commits November 13, 2026 13:00
…re uses

gotex-refdiff says a paper fell 0.1 points of word recall. It does not say
which words, so there is no way to tell a regression from an improvement the
metric mis-counts — which is #716's subject, and which #772 ran into head-on.

gotex-worddiff reports the multiset difference between two of OUR PDFs: the
words one holds that the other lacks, and the reverse. No reference; measuring
against the oracle is gotex-refdiff's job. Exit 0 same words, 1 different, 2 an
error.

⛔⛔ AND ITS FIRST ACT WAS TO CATCH ITS OWN AUTHOR, WHICH IS WHY THE EXTRACTOR
IS SHARED

The scratch probe this replaces read the PDFs with `pdfops text` and reported
that a revtex affiliation block had set as `CenterforTheoretical`,
`QiluNormalUniversity` — words with no spaces between them — and that #772 had
repaired it. That was published on #772 and on #716 before it was checked.

Reading the same two files through poppler's pdftotext, which is what
gotex-refdiff SCORES with, there is no such difference; and the engine's own
line dump shows the spaces present in both files, at identical coordinates. The
finding was two extractors disagreeing, dressed as an engine defect. Both
comments are corrected.

So the extraction itself — which binary, how it is found on PATH or through
pkgx, the poppler project pin that stops `pkgx pdftotext` failing with
MultipleProjects — moves into internal/pdftext, and gotex-refdiff is rewired
onto it. What does NOT move is what refdiff makes of the text: word recall, and
its genuine-empty versus tool-error distinction. Those are scoring semantics,
not extraction.

WHAT IS TESTED

 - the shapes a line-breaking change makes: a word split across a hyphen on one
   side and whole on the other, a fused token
 - a word both files hold is not a difference, and the same words in a
   different order exit 0
 - it is a MULTISET: three occurrences against two IS a difference
 - ⛔ a failed extraction is an error, never an empty page — otherwise a missing
   poppler reports every word of the other file as a difference, a maximal and
   confident meaningless answer
 - an absent or zero-byte file, likewise
 - internal/pdftext: the poppler pin, a tool found on PATH, and a missing tool
   that must error rather than return no text

The repository's own gate caught the missing .gitignore row
(TestEveryCommandIsIgnoredAtTheRoot).

Refs #716, #772.

Co-Authored-By: Claude Opus 5 <[email protected]>
…egression

#772 lost 0.1 and 0.2 points of word recall on two revtex papers and I could
not say why. The new tool says why, and most of it is not the engine.

⛔ pdftotext WITHOUT -layout READS A TWO-COLUMN PAGE AS ONE STREAM and fuses the
end of one column's line onto the start of another's. These are real tokens
from 2607.14549:

	disFigure   distribhe   participaentire   quaThe   respecIn
	transforlution   matTo   quag   quasiof   reperiodic

WHICH boundaries fuse depends on where the lines break, so a line-breaking
change moves them. On that paper the plain extraction reports 36 and 37 words
differing between the two builds; with -layout it reports 23 and 18, and every
fused token above is gone. What is left is the change itself: char-/acterized →
characterized, follow-/ing → following, in-/dicated, repre-/sent,
respec-/tively, sys-/tems, transfor-/mations.

⭐ AND THE SCORE MOVES WITH IT. Re-scoring #772's two papers with -layout
extraction (a throwaway build of gotex-refdiff, not this commit):

	2607.14914   plain -0.2  ->  -layout  1327 vs 1327 words, NO difference
	2607.14549   plain -0.1  ->  -layout  1020 vs 1019 words, ONE word

So one of the two regressions was the extractor fusing columns, and the other
is a single word.

⚠⚠ THIS IS NOT A PROPOSAL TO SWITCH THE SCORER. -layout moves the ABSOLUTE
scores by nine points on BOTH sides (2607.14549: 96.5% -> 87.6%), because the
padding it inserts changes tokenisation everywhere, including the reference's.
Every historical number would move. It is a diagnostic for reading a delta, and
gotex-refdiff is untouched here.

The flag is on gotex-worddiff; internal/pdftext.CaptureRunner takes opts and
places them BEFORE the file, where pdftotext takes its options. The mutation
was run: with the opts appended after the path instead, the test goes red
(`cat -u` becomes `cat f - -u`, which reads a file that is not there).

Refs #716, #772.

Co-Authored-By: Claude Opus 5 <[email protected]>
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.

1 participant