Fine-tune episode matching (to account for more alias titles in substring metric)

This commit is contained in:
Reinhard Pointner 2016-03-30 21:42:51 +00:00
parent 7279c52b2b
commit 97cf4800b8
1 changed files with 7 additions and 21 deletions

View File

@ -16,8 +16,6 @@ import java.time.temporal.ChronoUnit;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -34,6 +32,7 @@ import net.filebot.web.EpisodeFormat;
import net.filebot.web.Movie; import net.filebot.web.Movie;
import net.filebot.web.SeriesInfo; import net.filebot.web.SeriesInfo;
import net.filebot.web.SimpleDate; import net.filebot.web.SimpleDate;
import one.util.streamex.StreamEx;
public enum EpisodeMetrics implements SimilarityMetric { public enum EpisodeMetrics implements SimilarityMetric {
@ -200,31 +199,18 @@ public enum EpisodeMetrics implements SimilarityMetric {
protected Object[] fields(Object object) { protected Object[] fields(Object object) {
if (object instanceof Episode) { if (object instanceof Episode) {
Episode episode = (Episode) object; Episode e = (Episode) object;
Set<String> keywords = new LinkedHashSet<String>(); return StreamEx.of(e.getSeriesName(), e.getTitle()).append(e.getSeriesNames()).map(Normalization::removeTrailingBrackets).distinct().limit(5).toArray();
keywords.add(removeTrailingBrackets(episode.getSeriesName()));
keywords.add(removeTrailingBrackets(episode.getTitle()));
for (String it : episode.getSeriesNames()) {
keywords.add(removeTrailingBrackets(it));
}
// create array with size 4
Object[] f = new Object[4];
Iterator<String> keywordItr = keywords.iterator();
for (int i = 0; i < f.length; i++) {
f[i] = keywordItr.hasNext() ? keywordItr.next() : null;
}
return f;
} }
if (object instanceof File) { if (object instanceof File) {
File file = (File) object; File f = (File) object;
return new Object[] { file.getParentFile().getAbsolutePath(), file }; return new Object[] { f.getParentFile().getAbsolutePath(), f };
} }
if (object instanceof Movie) { if (object instanceof Movie) {
Movie movie = (Movie) object; Movie m = (Movie) object;
return new Object[] { movie.getName(), movie.getYear() }; return new Object[] { m.getName(), m.getYear() };
} }
return new Object[] { object }; return new Object[] { object };