Skip to content

Instantly share code, notes, and snippets.

@zopieux
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zopieux/8759785 to your computer and use it in GitHub Desktop.
Save zopieux/8759785 to your computer and use it in GitHub Desktop.
import re
import unicodedata
import difflib
import urlparse
def slugify(value):
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
value = re.sub('[^\w\s-]', '', value).strip().lower()
return re.sub('[-\s]+', '-', value)
def show_url(url, title):
return difflib.SequenceMatcher(None, urlparse.urlsplit(url).path.split('/')[-1], slugify(title)).ratio() < 0.8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment