Compare commits
No commits in common. "87a44997d7a9f7527feed183ab8c306d77d8fe12" and "8b4a1c65aa68ecadf20f6aed7541c7a6f4be6229" have entirely different histories.
87a44997d7
...
8b4a1c65aa
@ -28,26 +28,20 @@ def get_hidden_themes(viewings, token_id, token_secret):
|
|||||||
|
|
||||||
# Add hidden themes
|
# Add hidden themes
|
||||||
for date, data in viewings_filtered_watch_date.items():
|
for date, data in viewings_filtered_watch_date.items():
|
||||||
keyword_counts = {}
|
hidden_themes = set()
|
||||||
|
|
||||||
if len(data['viewings']) > 1:
|
if len(data['viewings']) > 1:
|
||||||
|
viewings_keywords = []
|
||||||
|
|
||||||
for viewing in data['viewings']:
|
for viewing in data['viewings']:
|
||||||
if 'keywords' in viewing:
|
if 'keywords' in viewing:
|
||||||
for keyword in viewing['keywords']:
|
viewings_keywords.append(set(viewing['keywords']))
|
||||||
if keyword in keyword_counts.keys():
|
|
||||||
keyword_counts[keyword] += 1
|
|
||||||
else:
|
|
||||||
keyword_counts[keyword] = 1
|
|
||||||
|
|
||||||
keyword_counts = {k: v for k, v in sorted(keyword_counts.items(), key=lambda item: item[1], reverse=True)}
|
if len(viewings_keywords) > 1:
|
||||||
hidden_themes = {}
|
hidden_themes = set.intersection(*viewings_keywords)
|
||||||
|
|
||||||
for keyword in keyword_counts:
|
if hidden_themes != set():
|
||||||
rating = float(keyword_counts[keyword]) / float(len(data['viewings']))
|
viewings_filtered_watch_date[date]['hidden_themes'] = list(hidden_themes)
|
||||||
if rating > 0.5:
|
|
||||||
hidden_themes[keyword] = rating
|
|
||||||
|
|
||||||
viewings_filtered_watch_date[date]['hidden_themes'] = hidden_themes
|
|
||||||
|
|
||||||
return viewings_filtered_watch_date
|
return viewings_filtered_watch_date
|
||||||
|
|
||||||
@ -68,18 +62,7 @@ def build_page(hidden_themes):
|
|||||||
row_data = []
|
row_data = []
|
||||||
row_data.append(str(date))
|
row_data.append(str(date))
|
||||||
row_data.append(VCinemaUtils.get_film_list(data['viewings']))
|
row_data.append(VCinemaUtils.get_film_list(data['viewings']))
|
||||||
if 'hidden_themes' in data and data['hidden_themes'] != {}:
|
row_data.append(("<br>".join(k for k in sorted(data['hidden_themes']))) if 'hidden_themes' in data else "N/A")
|
||||||
hidden_theme_labels = []
|
|
||||||
|
|
||||||
for hidden_theme in sorted(data['hidden_themes'].keys()):
|
|
||||||
if data['hidden_themes'][hidden_theme] == 1:
|
|
||||||
hidden_theme_labels.append(hidden_theme)
|
|
||||||
else:
|
|
||||||
hidden_theme_labels.append("<i>{} ({}%)</i>".format(hidden_theme, round(data['hidden_themes'][hidden_theme] * 100)))
|
|
||||||
|
|
||||||
row_data.append("<br>".join(hidden_theme_labels))
|
|
||||||
else:
|
|
||||||
row_data.append("N/A")
|
|
||||||
|
|
||||||
table += " | ".join(row_data)
|
table += " | ".join(row_data)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user