-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
* upstream/master: Add option to parse new references from plain text using GROBID… (#5614) update jlink plugin and gradle to 6.2 (#5964) Remove background command line window (#5965)
- Loading branch information
Showing
18 changed files
with
376 additions
and
46 deletions.
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This is https://github.com/marketplace/actions/gradle-wrapper-validation | ||
# It ensures that the jar file is from gradle and not by a strange third party. | ||
|
||
name: "Validate Gradle Wrapper" | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
validation: | ||
name: "Validation" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: gradle/wrapper-validation-action@v1 | ||
|
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
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
Binary file not shown.
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
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
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
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
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
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
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
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
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
77 changes: 77 additions & 0 deletions
77
src/main/java/org/jabref/logic/importer/fetcher/GrobidCitationFetcher.java
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 |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.jabref.logic.importer.fetcher; | ||
|
||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.stream.Collectors; | ||
|
||
import org.jabref.logic.importer.ImportFormatPreferences; | ||
import org.jabref.logic.importer.ParseException; | ||
import org.jabref.logic.importer.SearchBasedFetcher; | ||
import org.jabref.logic.importer.fileformat.BibtexParser; | ||
import org.jabref.logic.importer.util.GrobidService; | ||
import org.jabref.model.entry.BibEntry; | ||
import org.jabref.model.util.DummyFileUpdateMonitor; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class GrobidCitationFetcher implements SearchBasedFetcher { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(GrobidCitationFetcher.class); | ||
private static final String GROBID_URL = "http://grobid.cm.in.tum.de:8070"; | ||
private ImportFormatPreferences importFormatPreferences; | ||
private GrobidService grobidService; | ||
|
||
public GrobidCitationFetcher(ImportFormatPreferences importFormatPreferences) { | ||
this.importFormatPreferences = importFormatPreferences; | ||
this.grobidService = new GrobidService(GROBID_URL); | ||
} | ||
|
||
/** | ||
* Passes request to grobid server, using consolidateCitations option to improve result. | ||
* Takes a while, since the server has to look up the entry. | ||
* @return A BibTeX-String if extraction is successful and an empty String otherwise. | ||
*/ | ||
private String parseUsingGrobid(String plainText) { | ||
try { | ||
return grobidService.processCitation(plainText, GrobidService.ConsolidateCitations.WITH_METADATA); | ||
} catch (IOException e) { | ||
LOGGER.debug("Could not process citation", e); | ||
return ""; | ||
} | ||
} | ||
|
||
private Optional<BibEntry> parseBibToBibEntry(String bibtexString) { | ||
try { | ||
return BibtexParser.singleFromString(bibtexString, | ||
importFormatPreferences, new DummyFileUpdateMonitor()); | ||
} catch (ParseException e) { | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
@Override | ||
public List<BibEntry> performSearch(String query) { | ||
List<String> plainReferences = Arrays.stream( query.split( "\\r\\r+|\\n\\n+|\\r\\n(\\r\\n)+" ) ) | ||
.map(String::trim) | ||
.filter(str -> !str.isBlank()) | ||
.collect(Collectors.toCollection(ArrayList::new)); | ||
if (plainReferences.isEmpty()) { | ||
return Collections.emptyList(); | ||
} else { | ||
return plainReferences.stream() | ||
.map(reference -> parseBibToBibEntry(parseUsingGrobid(reference))) | ||
.flatMap(Optional::stream) | ||
.collect(Collectors.toList()); | ||
} | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "GROBID"; | ||
} | ||
} |
Oops, something went wrong.