bug fix in the AuthorMatch, implementation of the concat function in the model creation with jpath query

This commit is contained in:
miconis 2022-03-09 12:53:09 +01:00
parent 699612dd17
commit 3bc07c5881
3 changed files with 17 additions and 3 deletions

View File

@ -1,5 +1,5 @@
package eu.dnetlib.pace.config; package eu.dnetlib.pace.config;
public enum Type { public enum Type {
String, Int, List, JSON, URL String, Int, List, JSON, URL, StringConcat
} }

View File

@ -77,11 +77,13 @@ public class AuthorsMatch extends AbstractComparator {
//one person is inaccurate //one person is inaccurate
if (p1.isAccurate() ^ p2.isAccurate()) { if (p1.isAccurate() ^ p2.isAccurate()) {
//prepare data //prepare data
//data for the accurate person
String name = normalization(p1.isAccurate()? p1.getNormalisedFirstName() : p2.getNormalisedFirstName()); String name = normalization(p1.isAccurate()? p1.getNormalisedFirstName() : p2.getNormalisedFirstName());
String surname = normalization(p1.isAccurate()? p2.getNormalisedSurname() : p2.getNormalisedSurname()); String surname = normalization(p1.isAccurate()? p1.getNormalisedSurname() : p2.getNormalisedSurname());
//data for the inaccurate person
String fullname = normalization( String fullname = normalization(
p1.isAccurate() ? ((p1.getNormalisedFullname().isEmpty()) ? p1.getOriginal() : p1.getNormalisedFullname()) : (p2.getNormalisedFullname().isEmpty() ? p2.getOriginal() : p2.getNormalisedFullname()) p1.isAccurate() ? ((p2.getNormalisedFullname().isEmpty()) ? p2.getOriginal() : p2.getNormalisedFullname()) : (p1.getNormalisedFullname().isEmpty() ? p1.getOriginal() : p1.getNormalisedFullname())
); );
if (fullname.contains(surname)) { if (fullname.contains(surname)) {

View File

@ -15,6 +15,7 @@ import net.minidev.json.JSONArray;
import java.util.*; import java.util.*;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Collectors;
public class MapDocumentUtil { public class MapDocumentUtil {
@ -45,6 +46,17 @@ public class MapDocumentUtil {
.forEach(fi::add); .forEach(fi::add);
stringField.put(fdef.getName(), fi); stringField.put(fdef.getName(), fi);
break; break;
case StringConcat:
String[] jpaths = fdef.getPath().split("\\|\\|\\|");
stringField.put(
fdef.getName(),
new FieldValueImpl(Type.String,
fdef.getName(),
truncateValue(Arrays.stream(jpaths).map(jpath -> getJPathString(jpath, json)).collect(Collectors.joining(" ")),
fdef.getLength())
)
);
break;
} }
}); });
m.setFieldMap(stringField); m.setFieldMap(stringField);