* fine-tune SeriesRating episode differentiation metric

This commit is contained in:
Reinhard Pointner 2013-07-13 10:40:47 +00:00
parent e771cf39a5
commit ccd96ae5be
1 changed files with 16 additions and 4 deletions

View File

@ -32,6 +32,7 @@ import net.sourceforge.filebot.web.Episode;
import net.sourceforge.filebot.web.EpisodeFormat; import net.sourceforge.filebot.web.EpisodeFormat;
import net.sourceforge.filebot.web.Movie; import net.sourceforge.filebot.web.Movie;
import net.sourceforge.filebot.web.TheTVDBClient.SeriesInfo; import net.sourceforge.filebot.web.TheTVDBClient.SeriesInfo;
import net.sourceforge.filebot.web.TheTVDBSearchResult;
import com.ibm.icu.text.Transliterator; import com.ibm.icu.text.Transliterator;
@ -475,7 +476,9 @@ public enum EpisodeMetrics implements SimilarityMetric {
@Override @Override
public float getSimilarity(Object o1, Object o2) { public float getSimilarity(Object o1, Object o2) {
return max(getRating(o1), getRating(o2)) >= 0.4 ? 1 : 0; float r1 = getRating(o1);
float r2 = getRating(o2);
return max(r1, r2) >= 0.4 ? 1 : min(r1, r2) < 0 ? -1 : 0;
} }
private final Map<String, SeriesInfo> seriesInfoCache = new HashMap<String, SeriesInfo>(); private final Map<String, SeriesInfo> seriesInfoCache = new HashMap<String, SeriesInfo>();
@ -489,12 +492,21 @@ public enum EpisodeMetrics implements SimilarityMetric {
SeriesInfo seriesInfo = seriesInfoCache.get(n); SeriesInfo seriesInfo = seriesInfoCache.get(n);
if (seriesInfo == null && !seriesInfoCache.containsKey(n)) { if (seriesInfo == null && !seriesInfoCache.containsKey(n)) {
seriesInfo = WebServices.TheTVDB.getSeriesInfoByLocalIndex(((Episode) o).getSeriesName(), Locale.ENGLISH); try {
seriesInfo = WebServices.TheTVDB.getSeriesInfo((TheTVDBSearchResult) ((Episode) o).getSeries(), Locale.ENGLISH);
} catch (Exception e) {
seriesInfo = WebServices.TheTVDB.getSeriesInfoByLocalIndex(((Episode) o).getSeriesName(), Locale.ENGLISH);
}
seriesInfoCache.put(n, seriesInfo); seriesInfoCache.put(n, seriesInfo);
} }
if (seriesInfo != null && seriesInfo.getRatingCount() >= 20) { if (seriesInfo != null) {
return max(0, seriesInfo.getRating().floatValue()); if (seriesInfo.getRatingCount() > 0) {
float rating = max(0, seriesInfo.getRating().floatValue());
return seriesInfo.getRatingCount() >= 15 ? rating : rating / 2; // PENALIZE SHOWS WITH FEW RATINGS
} else {
return -1; // BIG PENALTY FOR SHOWS WITH 0 RATINGS
}
} }
} }
} catch (Exception e) { } catch (Exception e) {