implementation of the result title merge. main title with higher trust, distinct between the others

This commit is contained in:
miconis 2020-05-25 18:02:57 +02:00
parent 4b34872b44
commit da1e5cf557
3 changed files with 38 additions and 2 deletions

View File

@ -244,7 +244,25 @@ public class Result extends OafEntity implements Serializable {
subject = mergeLists(subject, r.getSubject());
//merge title lists: main title with higher trust and distinct between the others
StructuredProperty baseMainTitle = null;
if(title != null) {
baseMainTitle = getMainTitle(title);
title.remove(baseMainTitle);
}
StructuredProperty newMainTitle = null;
if(r.getTitle() != null) {
newMainTitle = getMainTitle(r.getTitle());
r.getTitle().remove(newMainTitle);
}
if (newMainTitle != null && compareTrust(this, r) < 0 )
baseMainTitle = newMainTitle;
title = mergeLists(title, r.getTitle());
if (title != null && baseMainTitle != null)
title.add(baseMainTitle);
relevantdate = mergeLists(relevantdate, r.getRelevantdate());
@ -294,4 +312,14 @@ public class Result extends OafEntity implements Serializable {
}
return a.size() > b.size() ? a : b;
}
private StructuredProperty getMainTitle(List<StructuredProperty> titles) {
//need to check if the list of titles contains more than 1 main title? (in that case, we should chose which main title select in the list)
for (StructuredProperty title: titles) {
if (title.getQualifier() != null && title.getQualifier().getClassid() != null)
if (title.getQualifier().getClassid().equals("main title"))
return title;
}
return null;
}
}

View File

@ -90,10 +90,18 @@ public class EntityMergerTest implements Serializable {
// verify authors
assertEquals(pub_merged.getAuthor().size(), 9);
assertEquals(AuthorMerger.countAuthorsPids(pub_merged.getAuthor()), 4);
//verify title
int count = 0;
for (StructuredProperty title: pub_merged.getTitle()){
if (title.getQualifier().getClassid().equals("main title"))
count++;
}
assertEquals(count, 1);
}
@Test
public void publicationMergerTest2() throws InstantiationException, IllegalAccessException, IOException {
public void publicationMergerTest2() throws InstantiationException, IllegalAccessException {
Publication pub_merged = DedupRecordFactory
.entityMerger(dedupId, publications2.iterator(), 0, dataInfo, Publication.class);