Include middle name in bibtex output, format initials#1356
Conversation
There was a problem hiding this comment.
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 includePerson.middleNamein BibTeXauthoroutput and add “.” for single-letter first/middle initials. - Apply the same formatting logic to BibTeX
editoroutput usingfullEditors. - 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
authorfield 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.
Signed-off-by: Luca Foppiano <luca@foppiano.org>
There was a problem hiding this comment.
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.
Signed-off-by: Luca Foppiano <luca@foppiano.org>
There was a problem hiding this comment.
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.
Signed-off-by: Luca Foppiano <luca@foppiano.org>
Signed-off-by: Luca Foppiano <luca@foppiano.org>
There was a problem hiding this comment.
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.
This PR fixes the issue reported in #1351:
Now the output should be correct: