def is_lyrics_content_ok(title, text): """Compare lyrics text to expected lyrics for given title""" setexpected = set(LYRICS_TEXTS[lyrics.slugify(title)].split()) settext = set(text.split()) setinter = setexpected.intersection(settext) # consider lyrics ok if they share 50% or more with the reference if len(setinter): ratio = 1.0 * max(len(setexpected), len(settext)) / len(setinter) return (ratio > .5 and ratio < 2) return False
def is_lyrics_content_ok(title, text): """Compare lyrics text to expected lyrics for given title""" setexpected = set(LYRICS_TEXTS[lyrics.slugify(title)].split()) settext = set(text.split()) setinter = setexpected.intersection(settext) # consider lyrics ok if they share 50% or more with the reference if len(setinter): ratio = 1.0 * max(len(setexpected), len(settext)) / len(setinter) return (ratio > .5 and ratio < 2.5) return False
def is_lyrics_content_ok(title, text): """Compare lyrics text to expected lyrics for given title""" keywords = LYRICS_TEXTS[lyrics.slugify(title)] return all(x in text.lower() for x in keywords)
def test_slugify(self): text = u"http://site.com/\xe7afe-au_lait(boisson)" self.assertEqual(lyrics.slugify(text), 'http://site.com/cafe_au_lait')