Esempio n. 1
0
 public void MatchScore_ignores_year_when_not_included_in_unsanitized_title()
 {
     var matchService = new MatchScoreService("The Matrix");
     int emptyYearScore = matchService.Score(new MatchScoreService.Fields { Year = "" });
     int givenYearScore = matchService.Score(new MatchScoreService.Fields { Year = "2003" });
     Assert.AreEqual(0, emptyYearScore);
     Assert.AreEqual(0, givenYearScore);
 }
Esempio n. 2
0
 private LookupResult parseOne(JToken o, string unsanitized_title)
 {
     int score = 0;
     score = new MatchScoreService(unsanitized_title).Score(new MatchScoreService.Fields
     {
         Year = (o["year"] ?? "").ToString(),
         Runtime = ((o["runtime"] ?? new JArray()).First ?? "").ToString(),
         PlotLength = (o["plot"] ?? o["simplePlot"] ?? "").ToString().Length
     });
     return new LookupResult
     {
         ImdbId = (o["idIMDB"] ?? "").ToString(),
         Title = (o["title"] ?? "").ToString(),
         Year = (o["year"] ?? "").ToString(),
         Rating = (o["rating"] ?? "").ToString(),
         Poster = (o["urlPoster"] ?? "").ToString(),
         SearchScore = score
     };
 }
Esempio n. 3
0
        private LookupResult parseOne(JToken o, string unsanitized_title)
        {
            int score = 0;

            score = new MatchScoreService(unsanitized_title).Score(new MatchScoreService.Fields
            {
                Year       = (o["year"] ?? "").ToString(),
                Runtime    = ((o["runtime"] ?? new JArray()).First ?? "").ToString(),
                PlotLength = (o["plot"] ?? o["simplePlot"] ?? "").ToString().Length
            });
            return(new LookupResult
            {
                ImdbId = (o["idIMDB"] ?? "").ToString(),
                Title = (o["title"] ?? "").ToString(),
                Year = (o["year"] ?? "").ToString(),
                Rating = (o["rating"] ?? "").ToString(),
                Poster = (o["urlPoster"] ?? "").ToString(),
                SearchScore = score
            });
        }
Esempio n. 4
0
 public int Score(MatchScoreService.Fields fields)
 {
     return RuntimeScore(fields.Runtime) + PlotScore(fields.PlotLength) + YearScore(fields.Year);
 }