1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-23 16:28:51 -05:00

* improved substring matching for instances like Doctor Who vs Doctor Who (2005), The Office vs The Office (US), etc

This commit is contained in:
Reinhard Pointner 2011-10-28 08:07:02 +00:00
parent 93d2e0f379
commit 1f0d9214fb
9 changed files with 29 additions and 15 deletions

View File

@ -5,6 +5,7 @@ package net.sourceforge.filebot.ui.rename;
import static java.util.Collections.*;
import static javax.swing.JOptionPane.*;
import static net.sourceforge.filebot.MediaTypes.*;
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
import static net.sourceforge.tuned.FileUtilities.*;
import static net.sourceforge.tuned.ui.TunedUtilities.*;
@ -65,7 +66,7 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
// find probable matches using name similarity > 0.9
for (SearchResult result : searchResults) {
if (metric.getSimilarity(normalize(query), normalize(result.getName())) > 0.9) {
if (metric.getSimilarity(normalizeName(query), normalizeName(result.getName())) > 0.9) {
probableMatches.add(result);
}
}
@ -107,9 +108,9 @@ class EpisodeListMatcher implements AutoCompleteMatcher {
}
private String normalize(String value) {
private String normalizeName(String value) {
// remove trailing braces, e.g. Doctor Who (2005) -> doctor who
return value.replaceAll("[(]([^)]*)[)]", "").trim().toLowerCase();
return removeTrailingBraces(value).toLowerCase();
}

View File

@ -4,6 +4,7 @@ package net.sourceforge.filebot.ui.rename;
import static java.lang.Math.*;
import static net.sourceforge.filebot.hash.VerificationUtilities.*;
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
import static net.sourceforge.tuned.FileUtilities.*;
import java.io.File;
@ -22,6 +23,7 @@ import net.sourceforge.filebot.similarity.SeasonEpisodeMatcher.SxE;
import net.sourceforge.filebot.vfs.AbstractFile;
import net.sourceforge.filebot.web.Date;
import net.sourceforge.filebot.web.Episode;
import net.sourceforge.filebot.web.Movie;
public enum MatchSimilarityMetric implements SimilarityMetric {
@ -121,8 +123,8 @@ public enum MatchSimilarityMetric implements SimilarityMetric {
protected String[] fields(Object object) {
if (object instanceof Episode) {
Episode e = (Episode) object;
return new String[] { e.getSeriesName(), e.getTitle() };
Episode episode = (Episode) object;
return new String[] { removeTrailingBraces(episode.getSeriesName()), episode.getTitle() };
}
if (object instanceof File) {
@ -130,6 +132,16 @@ public enum MatchSimilarityMetric implements SimilarityMetric {
return new String[] { getName(file.getParentFile()), getName(file) };
}
if (object instanceof Movie) {
Movie movie = (Movie) object;
return new String[] { movie.getName(), Integer.toString(movie.getYear()) };
}
if (object instanceof AbstractFile) {
AbstractFile file = (AbstractFile) object;
return new String[] { getNameWithoutExtension(file.getName()) };
}
return new String[] { object.toString() };
}

View File

@ -2,7 +2,7 @@
package net.sourceforge.filebot.web;
import static net.sourceforge.filebot.web.EpisodeListUtilities.*;
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
import java.util.List;
import java.util.Locale;

View File

@ -2,7 +2,7 @@
package net.sourceforge.filebot.web;
import static net.sourceforge.filebot.web.EpisodeListUtilities.*;
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
import static net.sourceforge.filebot.web.WebRequest.*;
import static net.sourceforge.tuned.XPathUtilities.*;

View File

@ -2,7 +2,7 @@
package net.sourceforge.filebot.web;
import static net.sourceforge.filebot.web.EpisodeListUtilities.*;
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
import static net.sourceforge.filebot.web.WebRequest.*;
import java.io.IOException;

View File

@ -2,7 +2,7 @@
package net.sourceforge.filebot.web;
import static net.sourceforge.filebot.web.EpisodeListUtilities.*;
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
import static net.sourceforge.filebot.web.WebRequest.*;
import static net.sourceforge.tuned.XPathUtilities.*;

View File

@ -2,7 +2,7 @@
package net.sourceforge.filebot.web;
import static net.sourceforge.filebot.web.EpisodeListUtilities.*;
import static net.sourceforge.filebot.web.EpisodeUtilities.*;
import static net.sourceforge.filebot.web.WebRequest.*;
import static net.sourceforge.tuned.XPathUtilities.*;

View File

@ -37,11 +37,6 @@ public final class StringUtilities {
}
public static boolean isNullOrEmpty(String value) {
return value == null || value.isEmpty();
}
/**
* Dummy constructor to prevent instantiation.
*/

View File

@ -12,6 +12,7 @@ AiRWAVES
ALLiANCE
ANiHLS
ARiGOLD
ASAP
AW
aWake
aXXo
@ -72,6 +73,7 @@ DiVERSiTY
DivXNL-Team
DMT
DnB
DNL
DOT
DOWN
ELECTRiC
@ -80,6 +82,7 @@ EnDoR
ESiR
ETM
EUHD
EuReKA
ExtraTorrentRG
FHM
FLAiTE
@ -110,6 +113,7 @@ HDFiRE
HDFL
HDi
HDL
HDMaNiAcS
HDMI
HDQ
HDVD
@ -140,6 +144,7 @@ JAVLiU
k2
KaKa
KOENiG
KRaLiMaRKo
KYR
Larceny
LEViTY
@ -262,6 +267,7 @@ VanRay
VCDVaULT
ViNYL
ViSiON
ViSTA
VOA
VoMiT
VoX