Sinónimos de un mismo vídeo cuentan una vez; lenguas -> Lengua árabe
This commit is contained in:
@@ -82,7 +82,7 @@ STOP = {'podcast', 'podcastclips', 'andaquenosabesna', 'andaquenosabesna', 'aqns
|
||||
'viral', 'parati', 'galaxoide', 'youtube', 'video', 'clips'}
|
||||
LABELS = { # clave normalizada -> texto a mostrar (sinónimos incluidos)
|
||||
'egipto': 'Egipto', 'egiptomania': 'Egipto', 'educacion': 'Educación', 'arabe': 'Lengua árabe',
|
||||
'lenguas': 'Lenguas', 'religion': 'Religiones', 'religiones': 'Religiones', 'magia': 'Magia',
|
||||
'lenguas': 'Lengua árabe', 'religion': 'Religiones', 'religiones': 'Religiones', 'magia': 'Magia',
|
||||
'burocracia': 'Burocracia', 'poligamia': 'Poligamia', 'economia': 'Economía',
|
||||
'gastronomia': 'Gastronomía', 'comidaegipcia': 'Comida egipcia', 'robotica': 'Robótica',
|
||||
'tecnologia': 'Tecnología', 'agricultura': 'Agricultura', 'curiosidades': 'Curiosidades',
|
||||
@@ -97,16 +97,17 @@ def norm(tag):
|
||||
|
||||
|
||||
def topics(vids):
|
||||
count, raw = Counter(), {}
|
||||
count = Counter()
|
||||
for v in vids:
|
||||
seen = set()
|
||||
for tag in re.findall(r'#(\w+)', v['desc']):
|
||||
k = norm(tag)
|
||||
if k in STOP or k in seen:
|
||||
if k in STOP:
|
||||
continue
|
||||
seen.add(k)
|
||||
label = LABELS.get(k) or (tag[0].upper() + tag[1:])
|
||||
raw[label] = label
|
||||
if label in seen: # sinónimos del mismo vídeo cuentan una sola vez
|
||||
continue
|
||||
seen.add(label)
|
||||
count[label] += 1
|
||||
ranked = [t for t, _ in sorted(count.items(), key=lambda kv: (-kv[1], kv[0]))]
|
||||
out = [t for t in ranked if t not in PINNED][:max(MAX_TOPICS - len(PINNED), 0)]
|
||||
|
||||
Reference in New Issue
Block a user