mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-24 08:48:51 -05:00
* fine-tune fuzzy matching
This commit is contained in:
parent
703e7024c2
commit
e1f76a671b
@ -27,7 +27,7 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
|||||||
|
|
||||||
private final Map<Object, Collection<SxE>> transformCache = synchronizedMap(new WeakHashMap<Object, Collection<SxE>>(64, 4));
|
private final Map<Object, Collection<SxE>> transformCache = synchronizedMap(new WeakHashMap<Object, Collection<SxE>>(64, 4));
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Collection<SxE> parse(Object object) {
|
protected Collection<SxE> parse(Object object) {
|
||||||
if (object instanceof Movie) {
|
if (object instanceof Movie) {
|
||||||
@ -61,7 +61,7 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
|||||||
|
|
||||||
private final Map<Object, Date> transformCache = synchronizedMap(new WeakHashMap<Object, Date>(64, 4));
|
private final Map<Object, Date> transformCache = synchronizedMap(new WeakHashMap<Object, Date>(64, 4));
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Date parse(Object object) {
|
protected Date parse(Object object) {
|
||||||
if (object instanceof Movie) {
|
if (object instanceof Movie) {
|
||||||
@ -141,7 +141,7 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
|||||||
return (float) (ceil(sum * 3) / 3);
|
return (float) (ceil(sum * 3) / 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected String[] normalize(Object[] objects) {
|
protected String[] normalize(Object[] objects) {
|
||||||
String[] names = new String[objects.length];
|
String[] names = new String[objects.length];
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Object[] fields(Object object) {
|
protected Object[] fields(Object object) {
|
||||||
if (object instanceof Episode) {
|
if (object instanceof Episode) {
|
||||||
Episode episode = (Episode) object;
|
Episode episode = (Episode) object;
|
||||||
@ -178,12 +178,12 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getSimilarity(Object o1, Object o2) {
|
public float getSimilarity(Object o1, Object o2) {
|
||||||
// normalize absolute similarity to similarity rank (4 ranks in total),
|
// normalize absolute similarity to similarity rank (6 ranks in total),
|
||||||
// so we are less likely to fall for false positives in this pass, and move on to the next one
|
// so we are less likely to fall for false positives in this pass, and move on to the next one
|
||||||
return (float) (floor(super.getSimilarity(o1, o2) * 4) / 4);
|
return (float) (floor(super.getSimilarity(o1, o2) * 6) / 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String normalize(Object object) {
|
protected String normalize(Object object) {
|
||||||
// simplify file name, if possible
|
// simplify file name, if possible
|
||||||
@ -210,7 +210,7 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
|||||||
return o1 instanceof File ? super.getSimilarity(o2, o1) : super.getSimilarity(o1, o2);
|
return o1 instanceof File ? super.getSimilarity(o2, o1) : super.getSimilarity(o1, o2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected long getLength(Object object) {
|
protected long getLength(Object object) {
|
||||||
if (object instanceof FileInfo) {
|
if (object instanceof FileInfo) {
|
||||||
@ -237,18 +237,18 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
|||||||
// inner metric
|
// inner metric
|
||||||
private final SimilarityMetric metric;
|
private final SimilarityMetric metric;
|
||||||
|
|
||||||
|
|
||||||
private EpisodeMetrics(SimilarityMetric metric) {
|
private EpisodeMetrics(SimilarityMetric metric) {
|
||||||
this.metric = metric;
|
this.metric = metric;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getSimilarity(Object o1, Object o2) {
|
public float getSimilarity(Object o1, Object o2) {
|
||||||
return metric.getSimilarity(o1, o2);
|
return metric.getSimilarity(o1, o2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected static String normalizeObject(Object object) {
|
protected static String normalizeObject(Object object) {
|
||||||
String name = object.toString();
|
String name = object.toString();
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
|||||||
return name.trim().toLowerCase();
|
return name.trim().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static SimilarityMetric[] defaultSequence(boolean includeFileMetrics) {
|
public static SimilarityMetric[] defaultSequence(boolean includeFileMetrics) {
|
||||||
// 1. pass: match by file length (fast, but only works when matching torrents or files)
|
// 1. pass: match by file length (fast, but only works when matching torrents or files)
|
||||||
// 2. pass: match by season / episode numbers
|
// 2. pass: match by season / episode numbers
|
||||||
@ -283,7 +283,7 @@ public enum EpisodeMetrics implements SimilarityMetric {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static SimilarityMetric verificationMetric() {
|
public static SimilarityMetric verificationMetric() {
|
||||||
return new MetricCascade(FileSize, FileName, SeasonEpisode, AirDate, Title, Name);
|
return new MetricCascade(FileSize, FileName, SeasonEpisode, AirDate, Title, Name);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user