diff --git a/nlp.py b/nlp.py index bf0b6a6aa..15535aa7e 100644 --- a/nlp.py +++ b/nlp.py @@ -385,11 +385,11 @@ def __init__(self, address, hub=0, authority=0, inlinks=None, outlinks=None): def HITS(query): """The HITS algorithm for computing hubs and authorities with respect to a query.""" pages = expand_pages(relevant_pages(query)) # in order to 'map' faithfully to pseudocode we - for p in pages: # won't pass the list of pages as an argument + for p in pages.values(): # won't pass the list of pages as an argument p.authority = 1 p.hub = 1 while True: # repeat until... convergence - for p in pages: + for p in pages.values(): p.authority = sum(x.hub for x in getInlinks(p)) # p.authority ← ∑i Inlinki(p).Hub p.hub = sum(x.authority for x in getOutlinks(p)) # p.hub ← ∑i Outlinki(p).Authority normalize(pages)