Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Movie: Check movie year against searched year #1340

Merged
merged 5 commits into from Jan 29, 2015
Merged

Movie: Check movie year against searched year #1340

merged 5 commits into from Jan 29, 2015

Conversation

MrChrisW
Copy link
Collaborator

Fixes #1339

Ping pong @jagtalon

Example:
image
image


Note: There may be a relevancy issue, example search for "Babe 2006" https://duckduckgo.com/?q=Babe+2006+rotten+tomatoes Fixed

@MrChrisW
Copy link
Collaborator Author

Regarding the relevancy note.
To fix this i'll add a check against the query/returned movie name if not exact we'll return all movies.

@@ -28,6 +28,20 @@
source = $(script).attr("src"),
query = source.match(/movie\/([^\/]+)/)[1];

//Check if the query contains a year
var year = decodeURIComponent(query).match(/\d{4}/gm),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might want to but \b around the capture? Otherwise it'll capture 4 digits as a substring. Should probably also check that the year is a valid, ie. > 1900 and maybe < current year + 5 (to look for upcoming movies)?

@MrChrisW
Copy link
Collaborator Author

@moollaza
Changes:

  • Year is being validated like year = (year >= 1900 && year <= new Date().getFullYear()+5) ? year : null;
  • Not year "matching" if the title contains a year.

Regrading the use of exactMatch or boost I've tested this and it does change the order of movies but won't return an exact match.

Two options:

  1. Return all movies and prioritise the one that matches a searched date using exactMatch
    Example:
    robocop 1987 vs robocop 2014
  2. Return an exact match using the current singleResult implementation.

@jagtalon
Copy link
Member

jagtalon commented Jan 1, 2015

@MrChrisW Nice--what about queries like "RoboCop (2014 film) rotten tomatoes"?

It looks like trim doesn't work on IE 8 either: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/Trim

@jagtalon
Copy link
Member

jagtalon commented Jan 1, 2015

Also would like some indentation in there. :)

@MrChrisW
Copy link
Collaborator Author

MrChrisW commented Jan 2, 2015

@jagtalon The main duckduckhack JS contains the String.prototype.trim polyfill so using trim shouldn't be an issue.

@MrChrisW
Copy link
Collaborator Author

MrChrisW commented Jan 2, 2015

@jagtalon That's a wonderful query "RoboCop (2014 film) rotten tomatoes" 😆 Thanks for the curve ball ⚽

Few options when comparing the query to the movie title.

  • Strip everything within round brackets / *\([^)]*\) */g
    • Probably not the best option as someone could search a movie that contains brackets in the title. Example: (500) Days of Summer
  • Strip keywords film, movie and round brackets.
    • Movies can contain these keywords and this isn't very maintainable 😦

Any other ideas?

@jagtalon
Copy link
Member

@MrChrisW Maybe check if there's \d{4} inside the brackets? Would that work?

@MrChrisW
Copy link
Collaborator Author

@jagtalon Best I can think of is below. This will allow the query `RoboCop (2014) rotten tomatoes.

 if (query.match(/\(.+?\)/g)) { #match parenthesis
     query = query.replace(/\(|\)/g, ''); #remove parenthesis
 }

However RoboCop (2014 film) rotten tomatoes is a little more difficult as you're dealing with arbatery keywords film movie etc.

@MrChrisW
Copy link
Collaborator Author

Ping @jagtalon

@jagtalon
Copy link
Member

@MrChrisW got it! 👍

jagtalon pushed a commit that referenced this pull request Jan 29, 2015
Movie: Check movie year against searched year
@jagtalon jagtalon merged commit 64d9a61 into duckduckgo:master Jan 29, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Movies disambiguation with year.
3 participants