Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
 def test_slugify(self):
     text = u"http://site.com/\xe7afe-au_lait(boisson)"
     self.assertEqual(lyrics.slugify(text), 'http://site.com/cafe_au_lait')
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
 def test_slugify(self):
     text = u"http://site.com/\xe7afe-au_lait(boisson)"
     self.assertEqual(lyrics.slugify(text), 'http://site.com/cafe_au_lait')