Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4c2918c

Browse files
Chipe1norvig
authored andcommitted
Changed normalize() (#439)
* Fixed normalize() * Update test for normalize()
1 parent 5b5d4df commit 4c2918c

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

nlp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ def normalize(pages):
318318
summed_hub = sum(page.hub**2 for _, page in pages.items())
319319
summed_auth = sum(page.authority**2 for _, page in pages.items())
320320
for _, page in pages.items():
321-
page.hub /= summed_hub
322-
page.authority /= summed_auth
321+
page.hub /= summed_hub**0.5
322+
page.authority /= summed_auth**0.5
323323

324324

325325
class ConvergenceDetector(object):

tests/test_nlp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def test_relevant_pages():
9595
def test_normalize():
9696
normalize(pageDict)
9797
print(page.hub for addr, page in nlp.pagesIndex.items())
98-
expected_hub = [1/91, 2/91, 3/91, 4/91, 5/91, 6/91] # Works only for sample data above
98+
expected_hub = [1/91**0.5, 2/91**0.5, 3/91**0.5, 4/91**0.5, 5/91**0.5, 6/91**0.5] # Works only for sample data above
9999
expected_auth = list(reversed(expected_hub))
100100
assert len(expected_hub) == len(expected_auth) == len(nlp.pagesIndex)
101101
assert expected_hub == [page.hub for addr, page in sorted(nlp.pagesIndex.items())]

0 commit comments

Comments
 (0)