diff --git a/CHANGELOG.md b/CHANGELOG.md index 97603ecfcc6..7c8a42e61f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -76,6 +76,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where opening BibTex file (doubleclick) from Folder with spaces not working. [#6487](https://github.com/JabRef/jabref/issues/6487) - We fixed an issue with saving large `.bib` files [#7265](https://github.com/JabRef/jabref/issues/7265) - We fixed an issue with very large page numbers [#7590](https://github.com/JabRef/jabref/issues/7590) +- We fixed an issue where the article title with curly brackets fails to download the arXiv link (pdf file). [#7633](https://github.com/JabRef/jabref/issues/7633) ### Removed diff --git a/src/main/java/org/jabref/logic/importer/fetcher/ArXiv.java b/src/main/java/org/jabref/logic/importer/fetcher/ArXiv.java index e0569146721..c63395708a0 100644 --- a/src/main/java/org/jabref/logic/importer/fetcher/ArXiv.java +++ b/src/main/java/org/jabref/logic/importer/fetcher/ArXiv.java @@ -136,7 +136,7 @@ private List searchForEntries(BibEntry entry) throws FetcherExceptio query = "doi:" + doi.get(); } else { Optional authorQuery = entry.getField(StandardField.AUTHOR).map(author -> "au:" + author); - Optional titleQuery = entry.getField(StandardField.TITLE).map(title -> "ti:" + title); + Optional titleQuery = entry.getField(StandardField.TITLE).map(title -> "ti:" + StringUtil.ignoreCurlyBracket(title)); query = OptionalUtil.toList(authorQuery, titleQuery).stream().collect(Collectors.joining("+AND+")); } @@ -146,7 +146,7 @@ private List searchForEntries(BibEntry entry) throws FetcherExceptio // Check if entry is a match StringSimilarity match = new StringSimilarity(); String arxivTitle = arxivEntry.get().title.orElse(""); - String entryTitle = entry.getField(StandardField.TITLE).orElse(""); + String entryTitle = StringUtil.ignoreCurlyBracket(entry.getField(StandardField.TITLE).orElse("")); if (match.isSimilar(arxivTitle, entryTitle)) { return OptionalUtil.toList(arxivEntry); diff --git a/src/main/java/org/jabref/model/strings/StringUtil.java b/src/main/java/org/jabref/model/strings/StringUtil.java index cc428a54455..4997b38444d 100644 --- a/src/main/java/org/jabref/model/strings/StringUtil.java +++ b/src/main/java/org/jabref/model/strings/StringUtil.java @@ -735,4 +735,8 @@ public static boolean containsIgnoreCase(String text, String searchString) { public static String substringBetween(String str, String open, String close) { return StringUtils.substringBetween(str, open, close); } + + public static String ignoreCurlyBracket(String title) { + return isNotBlank(title) ? title.replace("{", "").replace("}", "") : title; + } } diff --git a/src/test/java/org/jabref/logic/importer/fetcher/ArXivTest.java b/src/test/java/org/jabref/logic/importer/fetcher/ArXivTest.java index 2009f12e798..0ed6980ff10 100644 --- a/src/test/java/org/jabref/logic/importer/fetcher/ArXivTest.java +++ b/src/test/java/org/jabref/logic/importer/fetcher/ArXivTest.java @@ -95,6 +95,13 @@ void findFullTextByTitle() throws IOException { assertEquals(Optional.of(new URL("http://arxiv.org/pdf/cond-mat/0406246v1")), fetcher.findFullText(entry)); } + @Test + void findFullTextByTitleWithCurlyBracket() throws IOException { + entry.setField(StandardField.TITLE, "Machine versus {Human} {Attention} in {Deep} {Reinforcement} {Learning} {Tasks}"); + + assertEquals(Optional.of(new URL("https://arxiv.org/pdf/2010.15942v2")), fetcher.findFullText(entry)); + } + @Test void findFullTextByTitleAndPartOfAuthor() throws IOException { entry.setField(StandardField.TITLE, "Pause Point Spectra in DNA Constant-Force Unzipping"); @@ -103,6 +110,14 @@ void findFullTextByTitleAndPartOfAuthor() throws IOException { assertEquals(Optional.of(new URL("http://arxiv.org/pdf/cond-mat/0406246v1")), fetcher.findFullText(entry)); } + @Test + void findFullTextByTitleWithCurlyBracketAndPartOfAuthor() throws IOException { + entry.setField(StandardField.TITLE, "Machine versus {Human} {Attention} in {Deep} {Reinforcement} {Learning} {Tasks}"); + entry.setField(StandardField.AUTHOR, "Zhang, Ruohan and Guo"); + + assertEquals(Optional.of(new URL("https://arxiv.org/pdf/2010.15942v2")), fetcher.findFullText(entry)); + } + @Test void notFindFullTextByUnknownDOI() throws IOException { entry.setField(StandardField.DOI, "10.1529/unknown");