bonus points for primary matches (e.g. primary title matches filename > alias title matches folder path)

This commit is contained in:
Reinhard Pointner 2016-09-26 18:59:17 +08:00
parent c5be87c213
commit 4fbfc30d61
1 changed files with 5 additions and 6 deletions

View File

@ -191,12 +191,12 @@ public enum EpisodeMetrics implements SimilarityMetric {
// match all fields and average similarity // match all fields and average similarity
double sum = 0; double sum = 0;
for (int i1 = 0; i1 < f1.length; i1++) { for (int i = 0; i < f1.length; i++) {
for (int i2 = 0; i2 < f2.length; i2++) { for (int j = 0; j < f2.length; j++) {
float f = super.getSimilarity(f1[i1], f2[i2]); float f = super.getSimilarity(f1[i], f2[j]);
if (f > 0) { if (f > 0) {
// 2-sqrt(x) from 0 to 1 // 2-sqrt(x) from 0 to 1
double multiplier = 2 - Math.sqrt((double) (i1 + i2) / (f1.length + f2.length)); double multiplier = 2 - Math.sqrt((double) (i + j) / (f1.length + f2.length));
// bonus points for primary matches (e.g. primary title matches filename > alias title matches folder path) // bonus points for primary matches (e.g. primary title matches filename > alias title matches folder path)
sum += f * multiplier; sum += f * multiplier;
@ -205,8 +205,7 @@ public enum EpisodeMetrics implements SimilarityMetric {
} }
sum /= f1.length * f2.length; sum /= f1.length * f2.length;
// normalize into 3 similarity levels return sum >= 0.9 ? 1 : sum >= 0.1 ? 0.5f : 0;
return (float) (Math.ceil(Math.min(sum, 1) * 3) / 3);
} }
protected String[] normalize(Object[] objects) { protected String[] normalize(Object[] objects) {