added PacePerson to get name surname for authors having only fullname set

This commit is contained in:
Miriam Baglioni 2020-05-25 10:34:30 +02:00
parent b258f99ece
commit 8f51af4e9b
1 changed files with 56 additions and 42 deletions

View File

@ -7,6 +7,7 @@ import static eu.dnetlib.dhp.common.SparkSessionSupport.runWithSparkHiveSession;
import java.util.List;
import java.util.Optional;
import eu.dnetlib.dhp.common.PacePerson;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.spark.SparkConf;
@ -131,20 +132,32 @@ public class SparkOrcidToResultFromSemRelJob {
private static boolean enrichAuthor(AutoritativeAuthor autoritative_author, Author author) {
boolean toaddpid = false;
String author_name = author.getName();
String author_surname = author.getSurname();
if(StringUtils.isEmpty(author_name) || StringUtils.isEmpty(author_surname)){
PacePerson pp = new PacePerson(author.getFullname(), false);
if (pp.isAccurate()){
author_name = pp.getNormalisedFirstName();
author_surname = pp.getNormalisedSurname();
}
}
if (StringUtils.isNotEmpty(autoritative_author.getSurname())) {
if (StringUtils.isNotEmpty(author.getSurname())) {
if (StringUtils.isNotEmpty(author_surname)) {
if (autoritative_author
.getSurname()
.trim()
.equalsIgnoreCase(author.getSurname().trim())) {
.equalsIgnoreCase(author_surname.trim())) {
// have the same surname. Check the name
if (StringUtils.isNotEmpty(autoritative_author.getName())) {
if (StringUtils.isNotEmpty(author.getName())) {
if (StringUtils.isNotEmpty(author_name)) {
if (autoritative_author
.getName()
.trim()
.equalsIgnoreCase(author.getName().trim())) {
.equalsIgnoreCase(author_name.trim())) {
toaddpid = true;
}
// they could be differently written (i.e. only the initials of the name
@ -154,7 +167,7 @@ public class SparkOrcidToResultFromSemRelJob {
.getName()
.trim()
.substring(0, 0)
.equalsIgnoreCase(author.getName().trim().substring(0, 0))) {
.equalsIgnoreCase(author_name.trim().substring(0, 0))) {
toaddpid = true;
}
}
@ -185,6 +198,7 @@ public class SparkOrcidToResultFromSemRelJob {
return toaddpid;
}
private static boolean containsAllowedPid(Author a) {
Optional<List<StructuredProperty>> pids = Optional.ofNullable(a.getPid());
if (!pids.isPresent()) {