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

Fixieee #3970

Merged
merged 7 commits into from
Apr 21, 2018
Merged

Fixieee #3970

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions src/main/java/org/jabref/logic/importer/fetcher/IEEE.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
public class IEEE implements FulltextFetcher {

private static final Logger LOGGER = LoggerFactory.getLogger(IEEE.class);
private static final String STAMP_BASE_STRING_DOCUMENT = "/stamp/stamp.jsp?tp=&arnumber=";
private static final Pattern STAMP_PATTERN = Pattern.compile("(/stamp/stamp.jsp\\?t?p?=?&?arnumber=[0-9]+)");
private static final Pattern DOCUMENT_PATTERN = Pattern.compile("document/([0-9]+)/");

private static final Pattern PDF_PATTERN = Pattern.compile("\"(https://ieeexplore.ieee.org/ielx[0-9/]+\\.pdf[^\"]+)\"");
private static final String IEEE_DOI = "10.1109";
private static final String BASE_URL = "https://ieeexplore.ieee.org";
Expand All @@ -38,12 +41,20 @@ public Optional<URL> findFullText(BibEntry entry) throws IOException {
// Try URL first -- will primarily work for entries from the old IEEE search
Optional<String> urlString = entry.getField(FieldName.URL);
if (urlString.isPresent()) {
// Is the URL a direct link to IEEE?
Matcher matcher = STAMP_PATTERN.matcher(urlString.get());
if (matcher.find()) {

Matcher documentUrlMatcher = DOCUMENT_PATTERN.matcher(urlString.get());
if (documentUrlMatcher.find()) {
String docId = documentUrlMatcher.group(1);
stampString = STAMP_BASE_STRING_DOCUMENT + docId;
}

//You get this url if you export bibtex from IEEE
Matcher stampMatcher = STAMP_PATTERN.matcher(urlString.get());
if (stampMatcher.find()) {
// Found it
stampString = matcher.group(1);
stampString = stampMatcher.group(1);
}

}

// If not, try DOI
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/jabref/logic/importer/fetcher/IEEETest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

@FetcherTest
class IEEETest {

private IEEE finder;
private BibEntry entry;

Expand All @@ -34,6 +35,15 @@ void findByDOI() throws IOException {
finder.findFullText(entry));
}

@Test
void findByDocumentUrl() throws IOException {
entry.setField("url", "https://ieeexplore.ieee.org/document/7421926/");
assertEquals(
Optional.of(
new URL("https://ieeexplore.ieee.org/ielx7/6287639/7419931/07421926.pdf?tp=&arnumber=7421926&isnumber=7419931")),
finder.findFullText(entry));
}

@Test
void findByURL() throws IOException {
entry.setField("url", "https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=7421926");
Expand Down