From aa239ec673a0891e0adc45617a2239724d9e9daa Mon Sep 17 00:00:00 2001 From: Sandro La Bruzzo Date: Wed, 29 Nov 2023 11:17:41 +0100 Subject: [PATCH] Changed implementation of check similarity to verify exact match of name instead of the first char --- .../java/eu/dnetlib/dhp/oa/merge/AuthorMerger.java | 3 +-- .../java/eu/dnetlib/oa/merge/AuthorMergerTest.java | 10 +++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/dhp-common/src/main/java/eu/dnetlib/dhp/oa/merge/AuthorMerger.java b/dhp-common/src/main/java/eu/dnetlib/dhp/oa/merge/AuthorMerger.java index a1c3c2cc0..62e6764b7 100644 --- a/dhp-common/src/main/java/eu/dnetlib/dhp/oa/merge/AuthorMerger.java +++ b/dhp-common/src/main/java/eu/dnetlib/dhp/oa/merge/AuthorMerger.java @@ -222,7 +222,7 @@ public class AuthorMerger { nl -> pr .getName() .stream() - .anyMatch(nr -> nr.substring(0, 1).equalsIgnoreCase(nl.substring(0, 1))))) + .anyMatch(nr -> nr.equalsIgnoreCase(nl)))) return true; } @@ -236,7 +236,6 @@ public class AuthorMerger { } // - /** * Method to enrich ORCID information in one list of authors based on another list * @param baseAuthor the Author List in the OAF Entity diff --git a/dhp-common/src/test/java/eu/dnetlib/oa/merge/AuthorMergerTest.java b/dhp-common/src/test/java/eu/dnetlib/oa/merge/AuthorMergerTest.java index a11d49b1e..c0a8d6927 100644 --- a/dhp-common/src/test/java/eu/dnetlib/oa/merge/AuthorMergerTest.java +++ b/dhp-common/src/test/java/eu/dnetlib/oa/merge/AuthorMergerTest.java @@ -19,15 +19,19 @@ import eu.dnetlib.dhp.schema.oaf.Author; public class AuthorMergerTest { - @Test public void testEnrcichAuthor() throws Exception { final ObjectMapper mapper = new ObjectMapper(); BufferedReader pr = new BufferedReader(new InputStreamReader( - Objects.requireNonNull(AuthorMergerTest.class.getResourceAsStream("/eu/dnetlib/dhp/oa/merge/authors_publication_sample.json")))); + Objects + .requireNonNull( + AuthorMergerTest.class + .getResourceAsStream("/eu/dnetlib/dhp/oa/merge/authors_publication_sample.json")))); BufferedReader or = new BufferedReader(new InputStreamReader( - Objects.requireNonNull(AuthorMergerTest.class.getResourceAsStream("/eu/dnetlib/dhp/oa/merge/authors_orcid_sample.json")))); + Objects + .requireNonNull( + AuthorMergerTest.class.getResourceAsStream("/eu/dnetlib/dhp/oa/merge/authors_orcid_sample.json")))); TypeReference> aclass = new TypeReference>() { };