diff --git a/caliGraph.py b/caliGraph.py index c69c4e1..0df48d8 100755 --- a/caliGraph.py +++ b/caliGraph.py @@ -169,7 +169,7 @@ def removeTags(G): def pruneTags(G, minCons=2): - for n in list(G.nodes): + for n in sorted(list(G.nodes), key=lambda i: G.nodes[i]['score'] + len(G.nodes[i]['feedbacks'])/5 if 'score' in G.nodes[i] and 'feedbacks' in G.nodes[i] else 0): node = G.nodes[n] if node['t'] == 'tag': foundCon = 0 @@ -188,7 +188,7 @@ def pruneTags(G, minCons=2): def pruneRecommenders(G, minCons=2): - for n in list(G.nodes): + for n in sorted(list(G.nodes), key=lambda i: G.nodes[i]['score'] if 'score' in G.nodes[i] else 0): node = G.nodes[n] if node['t'] == 'recommender': foundCon = 0 @@ -638,11 +638,12 @@ def recommendNBooksTagBased(G, mu, std, n, removeTopListsB=True): def recommendNBooks(G, mu, std, n, removeTopListsB=True, removeUselessRecommenders=True): removeRestOfSeries(G) - removeBad(G, mu-std-1) + removeBad(G, mu-std-0.5) + removeBad(G, mu+std/2, groups=['recommender']) removeKeepBest(G, int(n*2) + 5, maxDistForRead=2) removeEdge(G) - removeHighSpanTags(G, 12) - removeHighSpanReadBooks(G, 6) + removeHighSpanTags(G, 10) + removeHighSpanReadBooks(G, 10) removeDangling(G, alsoBooks=False) pruneRecommenders(G, 13) pruneTags(G, 13)