Skip to content

Add PDF annotation services in CLI - #111

Open
lfoppiano wants to merge 3 commits into
masterfrom
feature/issue-79-annotation-services
Open

Add PDF annotation services in CLI #111
lfoppiano wants to merge 3 commits into
masterfrom
feature/issue-79-annotation-services

Conversation

@lfoppiano

Copy link
Copy Markdown
Member

Wire the GROBID PDF annotation endpoints into the CLI and batch pipeline. Each service declares its own Accept header, output suffix and write mode:

  • referenceAnnotations -> application/json, *.references.json
  • citationPatentAnnotations -> application/json, *.patent-citations.json
  • annotatePDF -> application/pdf (binary), *.annotated.pdf

The TEI -> JSON/Markdown conversion is skipped for these services. Documented in the Readme and covered by unit tests.

Closes #79

…ionPatentAnnotations)

Wire the GROBID PDF annotation endpoints into the CLI and batch pipeline.
Each service declares its own Accept header, output suffix and write mode:

- referenceAnnotations       -> application/json, *.references.json
- citationPatentAnnotations  -> application/json, *.patent-citations.json
- annotatePDF                -> application/pdf (binary), *.annotated.pdf

The TEI -> JSON/Markdown conversion is skipped for these services. Because the
annotation endpoints only honor a subset of the processing options, the client
warns once when the caller enables an option the selected service will ignore
(e.g. consolidate_header on annotatePDF). Documented in the Readme and covered
by unit tests.

Closes #79
The per-service Accept headers added by the previous commit never left
the client: call_api overwrote whatever the caller passed with its own
accept_type, so every request went out as application/xml and the
annotation endpoints were asked for the wrong representation. It went
unnoticed because the tests mock post(), one layer above the overwrite,
and assert on what process_pdf passes rather than on what is sent.

accept_type is now the fallback, not the last word. A caller that needs
a specific representation - JSON coordinates, or the annotated PDF - gets
it, and the two new tests exercise the request layer itself so the header
cannot silently be dropped again.

Verified against a stub server: annotatePDF now writes a real binary PDF
and referenceAnnotations real JSON, where all four services previously
wrote the same text/plain body.
@lfoppiano
lfoppiano force-pushed the feature/issue-79-annotation-services branch from f15cc3c to 067cda3 Compare August 14, 2026 07:57
The "text/plain" the client passed for the process* services never left
it: call_api replaced it with its own application/xml, so that is what
GROBID has been answering all along. Making the caller's header win in
the previous commit was right for the annotation endpoints, but it also
sent the TEI services out as text/plain for the first time - a type that
describes neither the payload nor what a server enforcing @produces
would accept.

The default descriptor now names the representation these services
actually return, and the two tests that pinned the old value follow.
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.

Adding PDF annotation services

1 participant