mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 00:38:52 -05:00
+ VoteRate metric
This commit is contained in:
parent
accac8c6ab
commit
e10d2ffd9e
@ -10,6 +10,8 @@ import static net.filebot.util.StringUtilities.*;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -17,7 +19,6 @@ import java.util.HashSet;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@ -562,8 +563,8 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getSimilarity(Object o1, Object o2) {
|
public float getSimilarity(Object o1, Object o2) {
|
||||||
float r1 = getRating(o1);
|
float r1 = getScore(o1);
|
||||||
float r2 = getRating(o2);
|
float r2 = getScore(o2);
|
||||||
|
|
||||||
if (r1 < 0 || r2 < 0)
|
if (r1 < 0 || r2 < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -571,7 +572,7 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
|||||||
return max(r1, r2);
|
return max(r1, r2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getRating(Object object) {
|
public float getScore(Object object) {
|
||||||
if (object instanceof Episode) {
|
if (object instanceof Episode) {
|
||||||
SeriesInfo seriesInfo = ((Episode) object).getSeriesInfo();
|
SeriesInfo seriesInfo = ((Episode) object).getSeriesInfo();
|
||||||
if (seriesInfo != null && seriesInfo.getRating() != null && seriesInfo.getRatingCount() != null) {
|
if (seriesInfo != null && seriesInfo.getRating() != null && seriesInfo.getRatingCount() != null) {
|
||||||
@ -588,6 +589,30 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
|||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
VoteRate(new SimilarityMetric() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getSimilarity(Object o1, Object o2) {
|
||||||
|
float r1 = getScore(o1);
|
||||||
|
float r2 = getScore(o2);
|
||||||
|
|
||||||
|
return max(r1, r2) >= 0.1 ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getScore(Object object) {
|
||||||
|
if (object instanceof Episode) {
|
||||||
|
SeriesInfo seriesInfo = ((Episode) object).getSeriesInfo();
|
||||||
|
if (seriesInfo != null && seriesInfo.getRating() != null && seriesInfo.getRatingCount() != null && seriesInfo.getStartDate() != null) {
|
||||||
|
long days = ChronoUnit.DAYS.between(seriesInfo.getStartDate().toLocalDate(), LocalDate.now());
|
||||||
|
if (days > 0) {
|
||||||
|
return (float) ((seriesInfo.getRatingCount().doubleValue() / days) * seriesInfo.getRating());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
// Match by (region) or (year) hints
|
// Match by (region) or (year) hints
|
||||||
RegionHint(new SimilarityMetric() {
|
RegionHint(new SimilarityMetric() {
|
||||||
|
|
||||||
@ -717,9 +742,9 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
|||||||
// 7 pass: prefer episodes that were aired closer to the last modified date of the file
|
// 7 pass: prefer episodes that were aired closer to the last modified date of the file
|
||||||
// 8 pass: resolve remaining collisions via absolute string similarity
|
// 8 pass: resolve remaining collisions via absolute string similarity
|
||||||
if (includeFileMetrics) {
|
if (includeFileMetrics) {
|
||||||
return new SimilarityMetric[] { FileSize, new MetricCascade(FileName, EpisodeFunnel), EpisodeBalancer, AirDate, MetaAttributes, SubstringFields, SeriesNameBalancer, SeriesName, RegionHint, Numeric, NumericSequence, SeriesRating, TimeStamp, FilePathBalancer, FilePath };
|
return new SimilarityMetric[] { FileSize, new MetricCascade(FileName, EpisodeFunnel), EpisodeBalancer, AirDate, MetaAttributes, SubstringFields, SeriesNameBalancer, SeriesName, RegionHint, Numeric, NumericSequence, SeriesRating, VoteRate, TimeStamp, FilePathBalancer, FilePath };
|
||||||
} else {
|
} else {
|
||||||
return new SimilarityMetric[] { EpisodeFunnel, EpisodeBalancer, AirDate, MetaAttributes, SubstringFields, SeriesNameBalancer, SeriesName, RegionHint, Numeric, NumericSequence, SeriesRating, TimeStamp, FilePathBalancer, FilePath };
|
return new SimilarityMetric[] { EpisodeFunnel, EpisodeBalancer, AirDate, MetaAttributes, SubstringFields, SeriesNameBalancer, SeriesName, RegionHint, Numeric, NumericSequence, SeriesRating, VoteRate, TimeStamp, FilePathBalancer, FilePath };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user