2014-04-19 02:30:29 -04:00
|
|
|
package net.filebot.similarity;
|
2009-07-26 12:54:24 -04:00
|
|
|
|
2014-04-19 02:30:29 -04:00
|
|
|
import static net.filebot.similarity.EpisodeMetrics.*;
|
2009-07-26 12:54:24 -04:00
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
|
|
|
import java.io.File;
|
2011-11-13 13:22:50 -05:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2009-07-26 12:54:24 -04:00
|
|
|
|
2013-07-13 06:01:33 -04:00
|
|
|
import org.junit.Test;
|
|
|
|
|
2016-03-13 09:32:26 -04:00
|
|
|
import net.filebot.web.Episode;
|
2016-03-13 13:35:31 -04:00
|
|
|
import net.filebot.web.SimpleDate;
|
2016-03-13 09:32:26 -04:00
|
|
|
|
2011-11-23 05:52:46 -05:00
|
|
|
public class EpisodeMetricsTest {
|
2014-03-18 16:16:39 -04:00
|
|
|
|
2011-11-13 01:33:54 -05:00
|
|
|
@Test
|
|
|
|
public void substringMetrics() {
|
2014-12-10 13:53:58 -05:00
|
|
|
Episode eY1T1 = new Episode("Doctor Who", 1, 1, "Rose");
|
2016-10-20 15:48:33 -04:00
|
|
|
|
2011-11-13 01:33:54 -05:00
|
|
|
File fY1T1 = new File("Doctor Who (2005)/Doctor Who - 1x01 - Rose");
|
|
|
|
File fY2T2 = new File("Doctor Who (1963)/Doctor Who - 1x01 - An Unearthly Child");
|
2014-03-18 16:16:39 -04:00
|
|
|
|
2016-10-20 15:48:33 -04:00
|
|
|
assertEquals(0.5, SubstringFields.getSimilarity(eY1T1, fY1T1), 0.1);
|
|
|
|
assertEquals(0.5, SubstringFields.getSimilarity(eY1T1, fY2T2), 0.1);
|
2011-11-13 01:33:54 -05:00
|
|
|
}
|
2014-03-18 16:16:39 -04:00
|
|
|
|
2011-11-13 13:22:50 -05:00
|
|
|
@Test
|
|
|
|
public void matcherLevel2() throws Exception {
|
|
|
|
List<File> files = new ArrayList<File>();
|
|
|
|
List<Episode> episodes = new ArrayList<Episode>();
|
2014-03-18 16:16:39 -04:00
|
|
|
|
2011-11-13 13:22:50 -05:00
|
|
|
files.add(new File("Greek/Greek - S01E19 - No Campus for Old Rules"));
|
|
|
|
files.add(new File("Veronica Mars - Season 1/Veronica Mars [1x19] Hot Dogs"));
|
2014-12-10 13:53:58 -05:00
|
|
|
episodes.add(new Episode("Veronica Mars", 1, 19, "Hot Dogs"));
|
|
|
|
episodes.add(new Episode("Greek", 1, 19, "No Campus for Old Rules"));
|
2014-03-18 16:16:39 -04:00
|
|
|
|
2011-11-22 13:26:50 -05:00
|
|
|
SimilarityMetric[] metrics = new SimilarityMetric[] { EpisodeIdentifier, SubstringFields };
|
2016-03-13 09:32:26 -04:00
|
|
|
List<Match<File, Episode>> m = new Matcher<File, Episode>(files, episodes, false, metrics).match();
|
2014-03-18 16:16:39 -04:00
|
|
|
|
2011-11-13 13:22:50 -05:00
|
|
|
assertEquals("Greek - S01E19 - No Campus for Old Rules", m.get(0).getValue().getName());
|
|
|
|
assertEquals("Greek - 1x19 - No Campus for Old Rules", m.get(0).getCandidate().toString());
|
|
|
|
assertEquals("Veronica Mars [1x19] Hot Dogs", m.get(1).getValue().getName());
|
|
|
|
assertEquals("Veronica Mars - 1x19 - Hot Dogs", m.get(1).getCandidate().toString());
|
|
|
|
}
|
2016-03-13 13:35:31 -04:00
|
|
|
|
|
|
|
@Test
|
|
|
|
public void nameIgnoreEmbeddedChecksum() {
|
|
|
|
assertEquals(1, Name.getSimilarity("test", "test [EF62DF13]"), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void numericIgnoreEmbeddedChecksum() {
|
|
|
|
assertEquals(1, Numeric.getSimilarity("S01E02", "Season 1, Episode 2 [00A01E02]"), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void numericNumbers() {
|
|
|
|
String fn = "SEED - 01 - [X 2.0]";
|
|
|
|
Episode e1 = new Episode("SEED", null, 1, "Enraged Eyes", 1, null, new SimpleDate(2004, 10, 9), null);
|
|
|
|
Episode s1 = new Episode("SEED", null, null, "EDITED", null, 1, new SimpleDate(2005, 1, 29), null);
|
|
|
|
|
|
|
|
assertEquals(0.5, Numeric.getSimilarity(fn, e1), 0.01);
|
|
|
|
assertEquals(0.5, Numeric.getSimilarity(fn, s1), 0.01);
|
|
|
|
}
|
|
|
|
|
2009-07-26 12:54:24 -04:00
|
|
|
}
|