Пример #1
0
def generate_keywords(text):
    """generates a list of keywords based on some text"""
    rake = Rake()
    keywords = rake.run(text)
    ret = []
    for (tag, strength) in keywords:
        if len(tag.split(' ')) < 3 and strength >= 3:
            ret.append(tag)
    return ret
Пример #2
0
def generate_keywords(text):
    """generates a list of 10 keywords based on some text"""
    rake = Rake()
    keywords = rake.run(text)
    ret = []
    for (tag, strength) in keywords:
        if len(tag.split(' ')) < 3 <= strength:
            ret.append(tag)
    if len(ret) > 10:
        ret = ret[:10]
    return ret