Skip to content

Include middle name in bibtex output, format initials#1356

Merged
lfoppiano merged 7 commits intomasterfrom
feature/middle-name-bibtex
Mar 20, 2026
Merged

Include middle name in bibtex output, format initials#1356
lfoppiano merged 7 commits intomasterfrom
feature/middle-name-bibtex

Conversation

@lfoppiano
Copy link
Copy Markdown
Member

This PR fixes the issue reported in #1351:

  • adds the middle name if present, do not add comma between first and middle name
  • add period if first or middle name are initials

Now the output should be correct:

curl -X POST "http://localhost:8070/api/processCitation" \
  -H "Accept: application/x-bibtex" \
  --data-urlencode "citations=Dill, K. A., Ozkan, S. B., Shell, M. S. & Weikl, T. R. The protein folding problem. Annu. Rev. Biophys. 37, 289–316 (2008)."

@article{-1,
  author = {Dill, K. A. and Ozkan, S. B. and Shell, M. S. and Weikl, T. R.},
  title = {The protein folding problem},
  journal = {Annu. Rev. Biophys},
  date = {2008},
  year = {2008},
  pages = {289--316},
  volume = {37}
}

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Grobid’s BibTeX serialization to include middle names/initials in author (and now also editor) fields and to add trailing periods for single-letter initials, addressing the missing-middle-name behavior reported in #1351.

Changes:

  • Update BiblioItem.toBibTeX() to include Person.middleName in BibTeX author output and add “.” for single-letter first/middle initials.
  • Apply the same formatting logic to BibTeX editor output using fullEditors.
  • Update REST-service BibTeX expectations in tests to reflect periods after single-letter initials.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
grobid-core/src/main/java/org/grobid/core/data/BiblioItem.java Enhances BibTeX formatting for author/editor by including middle names and adding periods for single-letter initials.
grobid-service/src/test/java/org/grobid/service/tests/GrobidRestServiceTest.java Updates expected BibTeX strings to match the new initials formatting behavior.
Comments suppressed due to low confidence (1)

grobid-service/src/test/java/org/grobid/service/tests/GrobidRestServiceTest.java:269

  • This PR addresses missing middle names and initial punctuation in BibTeX, but the service tests only cover adding periods for single-letter first names (e.g., "S."), not inclusion of middle names (e.g., "Dill, K. A."). Adding a REST test case that posts a citation containing a middle initial and asserts the BibTeX author field includes both initials (with periods) would prevent regressions of #1351.
    public void processCitationReturnsBibTeX() {
        Form form = new Form();
        form.param(GrobidRestService.CITATION, "Kolb, S., Wirtz G.: Towards Application Portability in Platform as a Service\n" +
            "Proceedings of the 8th IEEE International Symposium on Service-Oriented System Engineering (SOSE), Oxford, United Kingdom, April 7 - 10, 2014.");
        Response response = getClient().target(baseUrl()).path(GrobidPaths.PATH_CITATION)
                                       .request()
                                       .accept(BibTexMediaType.MEDIA_TYPE)
                                       .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE));
        assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
        assertEquals("@inproceedings{-1,\n" +
                "  author = {Kolb, S. and Wirtz, G.},\n" +
                "  booktitle = {Towards Application Portability in Platform as a Service Proceedings of the 8th IEEE International Symposium on Service-Oriented System Engineering (SOSE)},\n" +
                "  date = {2014},\n" +
                "  year = {2014},\n" +
//                "  year = {April 7 - 10, 2014},\n" +
                "  address = {Oxford, United Kingdom}\n" +
                "}\n",
            response.readEntity(String.class));

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread grobid-core/src/main/java/org/grobid/core/data/BiblioItem.java Outdated
Comment thread grobid-core/src/main/java/org/grobid/core/data/BiblioItem.java Outdated
Comment thread grobid-core/src/main/java/org/grobid/core/data/BiblioItem.java Outdated
Signed-off-by: Luca Foppiano <luca@foppiano.org>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

grobid-service/src/test/java/org/grobid/service/tests/GrobidRestServiceTest.java:270

  • The updated expectations cover adding periods for initials, but there is still no test asserting that BibTeX output includes middle names (the core behavior change in #1351). Adding a dedicated citation example like "Dill, K. A." and asserting author = {Dill, K. A. ...} would prevent regressions in middle-name handling and initial formatting together.
    public void processCitationReturnsBibTeX() {
        Form form = new Form();
        form.param(GrobidRestService.CITATION, "Kolb, S., Wirtz G.: Towards Application Portability in Platform as a Service\n" +
            "Proceedings of the 8th IEEE International Symposium on Service-Oriented System Engineering (SOSE), Oxford, United Kingdom, April 7 - 10, 2014.");
        Response response = getClient().target(baseUrl()).path(GrobidPaths.PATH_CITATION)
                                       .request()
                                       .accept(BibTexMediaType.MEDIA_TYPE)
                                       .post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE));
        assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
        assertEquals("@inproceedings{-1,\n" +
                "  author = {Kolb, S. and Wirtz, G.},\n" +
                "  booktitle = {Towards Application Portability in Platform as a Service Proceedings of the 8th IEEE International Symposium on Service-Oriented System Engineering (SOSE)},\n" +
                "  date = {2014},\n" +
                "  year = {2014},\n" +
//                "  year = {April 7 - 10, 2014},\n" +
                "  address = {Oxford, United Kingdom}\n" +
                "}\n",
            response.readEntity(String.class));
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread grobid-core/src/main/java/org/grobid/core/data/BiblioItem.java Outdated
Comment thread grobid-core/src/main/java/org/grobid/core/data/BiblioItem.java Outdated
Signed-off-by: Luca Foppiano <luca@foppiano.org>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread grobid-core/src/main/java/org/grobid/core/data/BiblioItem.java Outdated
Comment thread grobid-core/src/main/java/org/grobid/core/data/BiblioItem.java Outdated
Signed-off-by: Luca Foppiano <luca@foppiano.org>
Signed-off-by: Luca Foppiano <luca@foppiano.org>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lfoppiano lfoppiano merged commit 388f36e into master Mar 20, 2026
8 checks passed
@lfoppiano lfoppiano deleted the feature/middle-name-bibtex branch March 20, 2026 11:52
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.

/api/processCitation extract reference string missing author's middle name. Missed second names in bibtex and decapitalization of surnames

2 participants