Skip to content
Snippets Groups Projects
Commit 51824067 authored by ale's avatar ale
Browse files

prune targets in the transition model that would cause the same song to be repeated twice

parent e8f11785
No related branches found
No related tags found
No related merge requests found
...@@ -54,9 +54,13 @@ class MarkovModel(object): ...@@ -54,9 +54,13 @@ class MarkovModel(object):
norm_vec = [] norm_vec = []
tot = sum(target_map.itervalues()) tot = sum(target_map.itervalues())
cur = 0 cur = 0
for k, v in target_map.iteritems(): for target, count in target_map.iteritems():
cur += float(v) / tot # We explicitly drop this target to avoid repeating
norm_vec.append((cur, k)) # the same song more than once.
if target == key[-1]:
continue
cur += float(count) / tot
norm_vec.append((cur, target))
norm_map[key] = norm_vec norm_map[key] = norm_vec
self._map = norm_map self._map = norm_map
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment