Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix BibDataSetContextExtractor to quote replacement text #317

Merged
merged 1 commit into from May 18, 2018

Conversation

csw
Copy link
Contributor

@csw csw commented May 17, 2018

I've been seeing the following error fairly frequently: ```
! java.lang.IllegalArgumentException: Illegal group reference
! at java.util.regex.Matcher.appendReplacement(Matcher.java:857)
! at java.util.regex.Matcher.replaceAll(Matcher.java:955)
! at org.grobid.core.utilities.BibDataSetContextExtractor.extractContextSentence(BibDataSetContextExtractor.java:86)
! at org.grobid.core.utilities.BibDataSetContextExtractor.getCitationReferences(BibDataSetContextExtractor.java:73)
! at org.grobid.core.visualization.CitationsVisualizer.getJsonAnnotations(CitationsVisualizer.java:318)
! at org.grobid.service.process.GrobidRestProcessFiles.processPDFReferenceAnnotation(GrobidRestProcessFiles.java:598)
! at org.grobid.service.GrobidRestService.processPDFReferenceAnnotation(GrobidRestService.java:557)


It turns out that the BibDataSetContextExtractor isn't quoting the replacement string, so backslashes and dollar signs cause this error or unintended behavior.

This fixes the issue and adds a test case for it.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 38.813% when pulling 1ec624a on csw:bibdata-quoting into aa8652b on kermitt2:master.

@kermitt2
Copy link
Owner

Thank you Clayton for the PR !

@kermitt2 kermitt2 merged commit 31936a3 into kermitt2:master May 18, 2018
@csw csw deleted the bibdata-quoting branch May 30, 2018 20:02
de-code pushed a commit to elifesciences/grobid that referenced this pull request Nov 29, 2019
Fix BibDataSetContextExtractor to quote replacement text

Former-commit-id: 31936a3
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.

None yet

3 participants