Remove 'useless' read books from recommendation-graph (far away from all

unread books)
This commit is contained in:
Dominik Moritz Roth 2021-09-08 22:54:49 +02:00
parent c31a3d78e2
commit 4fa3a57cc7

View File

@ -276,6 +276,24 @@ def removeUnusedRecommenders(G):
else: # No unrated recommendation
G.remove_node(n)
def removeUselessReadBooks(G):
for n in list(G.nodes):
node = G.nodes[n]
if node['t'] == 'book':
for adj in G.adj[n]:
foundUnread = True
adjNode = G.nodes[adj]
for cousin in G.adj[adj]:
cousinNode = G.nodes[cousin]
if cousinNode['t']=='book' and 'score' in cousinNode:
break
else: # No unrated book here
foundUnread = False
if foundUnread:
break
else: # No unrated book in cousins
G.remove_node(n)
def scoreOpinions(G, globMu, globStd, errorFac=0.5):
for n in list(G.nodes):
node = G.nodes[n]
@ -517,6 +535,7 @@ def recommendNBooks(G, mu, std, n, removeTopListsB=True, removeUselessRecommende
removeDangling(G, alsoBooks=False)
pruneTags(G, 6)
removeBad(G, mu, groups=['book'])
removeUselessReadBooks(G)
pruneTags(G, 4.25)
pruneRecommenderCons(G, int(n/7)+1)
pruneAuthorCons(G, int(n/15))