From 5df87188c44a873fd78578e619ee61e51c5c144a Mon Sep 17 00:00:00 2001 From: Gena928 Date: Sun, 12 Apr 2020 20:05:57 +0300 Subject: [PATCH 1/4] Fixed a bug when "The abstract field is the concatenation of the AB and N2 fields." --- CHANGELOG.md | 1 + .../java/org/jabref/logic/importer/fileformat/RisImporter.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6df019fe891..e2db125f7b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,6 +83,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue where citation styles except the default "Preview" could not be used. [#56220](https://github.com/JabRef/jabref/issues/5622) - We fixed an issue where a warning was displayed when the title content is made up of two sentences. [#5832](https://github.com/JabRef/jabref/issues/5832) - We fixed an issue where an exception was thrown when adding a save action without a selected formatter in the library properties [#6069](https://github.com/JabRef/jabref/issues/6069) +- We fixed an issue when an "Abstract field" was duplicating text, when importing from RIS file (Neurons) [#6065](https://github.com/JabRef/jabref/issues/6065) ### Removed diff --git a/src/main/java/org/jabref/logic/importer/fileformat/RisImporter.java b/src/main/java/org/jabref/logic/importer/fileformat/RisImporter.java index 5c941f75fcb..6393bdc7a8c 100644 --- a/src/main/java/org/jabref/logic/importer/fileformat/RisImporter.java +++ b/src/main/java/org/jabref/logic/importer/fileformat/RisImporter.java @@ -199,7 +199,7 @@ public ParserResult importDatabase(BufferedReader reader) throws IOException { String oldAb = fields.get(StandardField.ABSTRACT); if (oldAb == null) { fields.put(StandardField.ABSTRACT, value); - } else { + } else if (!oldAb.equals(value) && !value.isEmpty()) { fields.put(StandardField.ABSTRACT, oldAb + OS.NEWLINE + value); } } else if ("UR".equals(tag) || "L2".equals(tag) || "LK".equals(tag)) { From 5b4ff31474ba39c7dcdc097c338df83171880567 Mon Sep 17 00:00:00 2001 From: Gena928 Date: Tue, 14 Apr 2020 16:57:36 +0300 Subject: [PATCH 2/4] Added test --- .../importer/fileformat/RISImporterTest.java | 17 ++++++++++++++ .../importer/fileformat/RisImporterTest9.bib | 7 ++++++ .../importer/fileformat/RisImporterTest9.ris | 23 +++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest9.bib create mode 100644 src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest9.ris diff --git a/src/test/java/org/jabref/logic/importer/fileformat/RISImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/RISImporterTest.java index 7e46c83d27f..381b9803e90 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/RISImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/RISImporterTest.java @@ -1,12 +1,18 @@ package org.jabref.logic.importer.fileformat; +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; import java.io.IOException; import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.List; import org.jabref.logic.util.StandardFileType; +import org.jabref.model.entry.BibEntry; +import org.jabref.model.entry.field.StandardField; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -48,4 +54,15 @@ public void testIfNotRecognizedFormat() throws IOException, URISyntaxException { Path file = Paths.get(RISImporterTest.class.getResource("RisImporterCorrupted.ris").toURI()); assertFalse(importer.isRecognizedFormat(file, StandardCharsets.UTF_8)); } + + @Test + public void testDuplicatesInAbstractField() throws URISyntaxException, IOException { + Path file = Paths.get(RISImporterTest.class.getResource("RisImporterTest9.ris").toURI()); + BufferedReader bufferedReader = new BufferedReader(new FileReader(file.toAbsolutePath().toString())); + List allEntries = importer.importDatabase(bufferedReader).getDatabase().getEntries(); + BibEntry firstEntry = allEntries.get(0); + assertEquals(394, firstEntry.getField(StandardField.ABSTRACT).get().length()); + } + + } diff --git a/src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest9.bib b/src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest9.bib new file mode 100644 index 00000000000..2e303a3ceff --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest9.bib @@ -0,0 +1,7 @@ +@book{, +author = {Smith, Bob and Doe, Jan and Brown, Judy and Martin, Steve and Clark, Joe}, +publisher = {Test Publisher}, +title = {Testing Book Title}, +volume = {1}, +year = {2015} +} diff --git a/src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest9.ris b/src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest9.ris new file mode 100644 index 00000000000..940f1c2705d --- /dev/null +++ b/src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest9.ris @@ -0,0 +1,23 @@ +TY - JOUR +T1 - Grid Cells for Conceptual Spaces? +AU - Kriegeskorte, Nikolaus +AU - Storrs, Katherine R. +Y1 - 2016/10/19 +PY - 2016 +N1 - doi: 10.1016/j.neuron.2016.10.006 +DO - 10.1016/j.neuron.2016.10.006 +T2 - Neuron +JF - Neuron +SP - 280 +EP - 284 +VL - 92 +IS - 2 +PB - Elsevier +N2 - ?Grid cells? encode an animal?s location and direction of movement in 2D physical environments via regularly repeating receptive fields. Constantinescu et al. (2016) report the first evidence of grid cells for 2D conceptual spaces. The work has exciting implications for mental representation and shows how detailed neural-coding hypotheses can be tested with bulk population-activity measures. +AB - ?Grid cells? encode an animal?s location and direction of movement in 2D physical environments via regularly repeating receptive fields. Constantinescu et al. (2016) report the first evidence of grid cells for 2D conceptual spaces. The work has exciting implications for mental representation and shows how detailed neural-coding hypotheses can be tested with bulk population-activity measures. +SN - 0896-6273 +M3 - doi: 10.1016/j.neuron.2016.10.006 +UR - https://doi.org/10.1016/j.neuron.2016.10.006 +Y2 - 2020/03/04 +ER - + From 8fe57dc25b44f5553c6f937546c0b0c9189b83c7 Mon Sep 17 00:00:00 2001 From: Gena928 Date: Tue, 14 Apr 2020 21:10:14 +0300 Subject: [PATCH 3/4] Ouch, now I understand the testing system for importing. --- .../importer/fileformat/RISImporterTest.java | 11 --------- .../importer/fileformat/RisImporterTest9.bib | 23 ++++++++++++++----- .../importer/fileformat/RisImporterTest9.ris | 6 ++--- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/test/java/org/jabref/logic/importer/fileformat/RISImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/RISImporterTest.java index 381b9803e90..965bd130c06 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/RISImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/RISImporterTest.java @@ -54,15 +54,4 @@ public void testIfNotRecognizedFormat() throws IOException, URISyntaxException { Path file = Paths.get(RISImporterTest.class.getResource("RisImporterCorrupted.ris").toURI()); assertFalse(importer.isRecognizedFormat(file, StandardCharsets.UTF_8)); } - - @Test - public void testDuplicatesInAbstractField() throws URISyntaxException, IOException { - Path file = Paths.get(RISImporterTest.class.getResource("RisImporterTest9.ris").toURI()); - BufferedReader bufferedReader = new BufferedReader(new FileReader(file.toAbsolutePath().toString())); - List allEntries = importer.importDatabase(bufferedReader).getDatabase().getEntries(); - BibEntry firstEntry = allEntries.get(0); - assertEquals(394, firstEntry.getField(StandardField.ABSTRACT).get().length()); - } - - } diff --git a/src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest9.bib b/src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest9.bib index 2e303a3ceff..7555e5422d1 100644 --- a/src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest9.bib +++ b/src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest9.bib @@ -1,7 +1,18 @@ -@book{, -author = {Smith, Bob and Doe, Jan and Brown, Judy and Martin, Steve and Clark, Joe}, -publisher = {Test Publisher}, -title = {Testing Book Title}, -volume = {1}, -year = {2015} +% Encoding: UTF-8 + +@Article{, + author = {Kriegeskorte, Nikolaus and Storrs, Katherine R.}, + title = {Grid Cells for Conceptual Spaces?}, + doi = {10.1016/j.neuron.2016.10.006}, + issn = {0896-6273}, + number = {2}, + pages = {280--284}, + url = {https://doi.org/10.1016/j.neuron.2016.10.006}, + volume = {92}, + abstract = {location and direction of movement in 2D physical environments via regularly repeating receptive fields.}, + comment = {doi: 10.1016/j.neuron.2016.10.006}, + journal = {Neuron}, + month = oct, + publisher = {Elsevier}, + year = {2016}, } diff --git a/src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest9.ris b/src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest9.ris index 940f1c2705d..496e17caa88 100644 --- a/src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest9.ris +++ b/src/test/resources/org/jabref/logic/importer/fileformat/RisImporterTest9.ris @@ -1,7 +1,7 @@ TY - JOUR T1 - Grid Cells for Conceptual Spaces? AU - Kriegeskorte, Nikolaus -AU - Storrs, Katherine R. +AU - Storrs, Katherine R. Y1 - 2016/10/19 PY - 2016 N1 - doi: 10.1016/j.neuron.2016.10.006 @@ -13,8 +13,8 @@ EP - 284 VL - 92 IS - 2 PB - Elsevier -N2 - ?Grid cells? encode an animal?s location and direction of movement in 2D physical environments via regularly repeating receptive fields. Constantinescu et al. (2016) report the first evidence of grid cells for 2D conceptual spaces. The work has exciting implications for mental representation and shows how detailed neural-coding hypotheses can be tested with bulk population-activity measures. -AB - ?Grid cells? encode an animal?s location and direction of movement in 2D physical environments via regularly repeating receptive fields. Constantinescu et al. (2016) report the first evidence of grid cells for 2D conceptual spaces. The work has exciting implications for mental representation and shows how detailed neural-coding hypotheses can be tested with bulk population-activity measures. +N2 - location and direction of movement in 2D physical environments via regularly repeating receptive fields. +AB - location and direction of movement in 2D physical environments via regularly repeating receptive fields. SN - 0896-6273 M3 - doi: 10.1016/j.neuron.2016.10.006 UR - https://doi.org/10.1016/j.neuron.2016.10.006 From 880a8251de1403b6248174e703bd98a22ffa6f07 Mon Sep 17 00:00:00 2001 From: Gena928 Date: Tue, 14 Apr 2020 21:12:02 +0300 Subject: [PATCH 4/4] Removed unnecessary imports --- .../jabref/logic/importer/fileformat/RISImporterTest.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/test/java/org/jabref/logic/importer/fileformat/RISImporterTest.java b/src/test/java/org/jabref/logic/importer/fileformat/RISImporterTest.java index 965bd130c06..7e46c83d27f 100644 --- a/src/test/java/org/jabref/logic/importer/fileformat/RISImporterTest.java +++ b/src/test/java/org/jabref/logic/importer/fileformat/RISImporterTest.java @@ -1,18 +1,12 @@ package org.jabref.logic.importer.fileformat; -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.FileReader; import java.io.IOException; import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.List; import org.jabref.logic.util.StandardFileType; -import org.jabref.model.entry.BibEntry; -import org.jabref.model.entry.field.StandardField; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test;