Beispiel #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
Beispiel #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
Beispiel #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)
Beispiel #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')
Beispiel #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)
Beispiel #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')