Last active
August 29, 2015 13:55
-
-
Save zopieux/8759785 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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