Python 将杂乱的单词减少为单词种子

Python 将杂乱的单词减少为单词种子,python,api,seed,Python,Api,Seed,例如,spotify API歌曲类型: ['alternative rock', 'comic', 'funk rock', 'garage rock', 'indie rock', 'pop rock', 'post-grunge', 'rock'] ['g funk', 'gangster rap', 'hip hop', 'pop rap', 'rap', 'west coast rap'] ['canadian pop', 'dance pop', 'pop', 'pop

例如,spotify API歌曲类型:

['alternative rock', 'comic', 'funk rock', 'garage rock', 'indie rock', 'pop rock', 'post-grunge', 'rock']   

['g funk', 'gangster rap', 'hip hop', 'pop rap', 'rap', 'west coast rap']   

['canadian pop', 'dance pop', 'pop', 'pop christmas']      
三个列表代表了三种歌曲的类型。但是这些类型看起来很混乱,我可以很容易地“提取”出“类型种子”,即三首歌曲是

rock
rap
pop
分别

我怎样才能把这些乱七八糟的单词简化成单词种子呢?
thx

好吧,如果你有一个种子列表,我们可以,例如,计算每种类型种子的出现次数,并返回最大权重的一个。 假设种子列表称为“种子”,类型列表称为“类型”。我们应该交叉检查所有种子类型组合,并为某些结构增加权重

def max_seed_return (seeds, genres):
    # appending weigths to dictionary
    weights= {seed:0 for seed in seeds}
    for genre in genres:
        for seed in seeds:
            if seed in genre:
            weights[seed]+=1
    max_weight, result = 0, None
    # getting result genre with biggest weigth
    for seed, seed_weight in weights.items:
        if seed_weight>max_weight:
            max_weight=seed_weight
            result=seed
    #returns it or None if no seeds is found in genres
    return result

你需要在流派和“流派种子”之间进行某种映射。你已经有了有限的种子词列表吗?是的,我有像“流行音乐”、“摇滚乐”这样的种子词列表