removed the outdated portion: screening parameter etc

This commit is contained in:
pythagoraswitch 2018-09-26 23:56:29 +02:00
parent 024c1008fb
commit 81cfe9c9d8

View file

@ -45,7 +45,6 @@ class Engine:
'channels': { 'channels': {
'globalKeywords': {'locked': False, 'value': 8}, 'globalKeywords': {'locked': False, 'value': 8},
'userKeywords': {'locked': False, 'value': 8} 'userKeywords': {'locked': False, 'value': 8}
# 'screenings': {'locked': True, 'value': 2}
}, },
'globalKeywords': {}, 'globalKeywords': {},
} }
@ -202,8 +201,7 @@ class Engine:
} }
# NOTE for future improvement: vids_exclude element unit could be clip or in/out time pairs, rather than playlist.
# The same playlist could be played in the grid view as long as these are differenct clips or separate times.
def get_recommendations(self, user, vids_exclude = []): def get_recommendations(self, user, vids_exclude = []):
channels = {k: v.get('value', 0) for k, v in self.state['channels'].items()} channels = {k: v.get('value', 0) for k, v in self.state['channels'].items()}
sliders = {k: v.get('value', 0) for k, v in self.state['globalKeywords'].items()} sliders = {k: v.get('value', 0) for k, v in self.state['globalKeywords'].items()}
@ -255,23 +253,7 @@ class Engine:
playlists, playlists,
key=lambda playlist: -score[playlist['name']] key=lambda playlist: -score[playlist['name']]
) )
videos += playlists[:channels['globalKeywords']] videos += playlists[:16 - channels['userKeywords']]
playlists = playlists[channels['globalKeywords']:]
# Count products the user has seen
count = defaultdict(lambda: 0)
for event in user.get('events', []):
if event.get('data', {}).get('product'):
count[event['data']['product']] += 1
# For each product in playlist tags, increment score by count
for playlist in playlists:
score[playlist['name']] = random.random()
for tag in set(playlist['tags']) & set(count):
score[playlist['name']] += count[tag]
# Select highest scoring playlists
videos += sorted(
playlists,
key=lambda playlist: -score[playlist['name']]
)[:16 - channels['userKeywords'] - channels['globalKeywords']]
# Shuffle playlists (randomize layout) and shift clips (randomize start) # Shuffle playlists (randomize layout) and shift clips (randomize start)
random.shuffle(videos) random.shuffle(videos)
return [{ return [{