Skip to content

Instantly share code, notes, and snippets.

@ryszard
Created May 28, 2010 12:45
Show Gist options
  • Save ryszard/417110 to your computer and use it in GitHub Desktop.
Save ryszard/417110 to your computer and use it in GitHub Desktop.
from ngrams import Ngrams, CharNgrams
def distance(left, right):
season = abs(int(left.get('season') or 0) - int(right.get('season') or 0))
number = abs(int(left.get('number') or 0) - int(right.get('number') or 0))
title = 1 - (CharNgrams(left.get('title', '')) * CharNgrams(right.get('title', '')))
#description = 1 - (Ngrams(left.get('description', '')) * Ngrams(right.get('description', '')))
return season * 5 + number * 5 + title * 15# + description * 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment