-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Implimented arXivId Parsing for PDF with arXivId #12335
Merged
+83
−2
Merged
Changes from 15 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
220ddac
Implimented arXivId Parsing forPDF with arXivId
ar-rana 32e9867
added Optional parameter
ar-rana 9c80e04
Merge branch 'main' into feature/arXivId
ar-rana 89de378
merged fixes
ar-rana 28755cf
removed csl-styles
ar-rana 06b6bb0
fixed null arxiv issue on external imports
ar-rana 457bb3f
Improved getArxivId Implementation
ar-rana a653de5
reduced nesting and added arxiv constant
ar-rana 06c771b
reduced nesting
ar-rana 1512d7e
modified testcase
ar-rana 0308a0b
Merge remote-tracking branch 'upstream/main' into feature/arXivId
Siedlerchr 15ac9a2
Merge branch 'main' into feature/arXivId
Siedlerchr a21f893
fix abbrev repo
Siedlerchr 774ee84
removed unnecessary 'if' clause
ar-rana 148b716
Merge branch 'main' into feature/arXivId
koppor 126cbaa
Use EPRINTTYPE
koppor 03fede4
Update src/main/java/org/jabref/logic/importer/fileformat/PdfContentI…
koppor cfe1664
WIP
koppor b3d8556
Add completion using arXiv ID
koppor 18673c8
Adapt test case
koppor 1f112a2
Fix test name
koppor 5e961fa
"Fix2 number and year extraction for arXiv
koppor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.entry.LinkedFile; | ||
import org.jabref.model.entry.field.StandardField; | ||
import org.jabref.model.entry.identifier.ArXivIdentifier; | ||
import org.jabref.model.entry.identifier.DOI; | ||
import org.jabref.model.entry.types.EntryType; | ||
import org.jabref.model.entry.types.StandardEntryType; | ||
|
@@ -51,6 +52,8 @@ public class PdfContentImporter extends PdfImporter { | |
|
||
private static final Pattern YEAR_EXTRACT_PATTERN = Pattern.compile("\\d{4}"); | ||
|
||
private static final int ARXIV_PREFIX_LENGTH = "arxiv:".length(); | ||
|
||
// input lines into several lines | ||
private String[] lines; | ||
|
||
|
@@ -372,11 +375,13 @@ Optional<BibEntry> getEntryFromPDFContent(String firstpageContents, String lineS | |
String volume = null; | ||
String number = null; | ||
String pages = null; | ||
String arXivId = null; | ||
// year is a class variable as the method extractYear() uses it; | ||
String publisher = null; | ||
|
||
EntryType type = StandardEntryType.InProceedings; | ||
if (curString.length() > 4) { | ||
arXivId = getArXivId(null); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Passing null is really bad style. This neesd to be fixed eventually!! I will approve nevertheless. Too much time spend on this. |
||
// special case: possibly conference as first line on the page | ||
extractYear(); | ||
doi = getDoi(null); | ||
|
@@ -396,6 +401,7 @@ Optional<BibEntry> getEntryFromPDFContent(String firstpageContents, String lineS | |
} | ||
} | ||
|
||
arXivId = getArXivId(arXivId); | ||
// start: title | ||
fillCurStringWithNonEmptyLines(); | ||
title = streamlineTitle(curString); | ||
|
@@ -515,6 +521,7 @@ Optional<BibEntry> getEntryFromPDFContent(String firstpageContents, String lineS | |
} | ||
} else { | ||
doi = getDoi(doi); | ||
arXivId = getArXivId(arXivId); | ||
|
||
if ((publisher == null) && curString.contains("IEEE")) { | ||
// IEEE has the conference things at the end | ||
|
@@ -565,13 +572,16 @@ Optional<BibEntry> getEntryFromPDFContent(String firstpageContents, String lineS | |
if (doi != null) { | ||
entry.setField(StandardField.DOI, doi); | ||
} | ||
if (arXivId != null) { | ||
entry.setField(StandardField.EPRINT, arXivId); | ||
koppor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
if (series != null) { | ||
entry.setField(StandardField.SERIES, series); | ||
} | ||
if (volume != null) { | ||
entry.setField(StandardField.VOLUME, volume); | ||
} | ||
if (number != null) { | ||
if (number != null && number.chars().allMatch(Character::isDigit)) { | ||
koppor marked this conversation as resolved.
Show resolved
Hide resolved
|
||
entry.setField(StandardField.NUMBER, number); | ||
} | ||
if (pages != null) { | ||
|
@@ -600,6 +610,26 @@ private String getDoi(String doi) { | |
return doi; | ||
} | ||
|
||
private String getArXivId(String arXivId) { | ||
if (arXivId != null) { | ||
return arXivId; | ||
} | ||
|
||
String arXiv = curString.split(" ")[0]; | ||
arXivId = ArXivIdentifier.parse(arXiv).map(ArXivIdentifier::asString).orElse(null); | ||
|
||
if (arXivId == null || curString.length() < arXivId.length() + ARXIV_PREFIX_LENGTH) { | ||
return arXivId; | ||
} | ||
// The arxiv string also contains the year | ||
curString = curString.substring(arXivId.length() + ARXIV_PREFIX_LENGTH); | ||
extractYear(); | ||
curString = ""; | ||
proceedToNextNonEmptyLine(); | ||
|
||
return arXivId; | ||
} | ||
|
||
private String getFirstPageContents(PDDocument document) throws IOException { | ||
PDFTextStripper stripper = new PDFTextStripper(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an example why comments are to be avoided as much as possible, this line compiles fine, runs fine but the comment above it is misguiding. Please move comment to its correct location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure