diff --git a/nlp.py b/nlp.py index bf0b6a6aa..622a7bb40 100644 --- a/nlp.py +++ b/nlp.py @@ -318,8 +318,8 @@ def normalize(pages): summed_hub = sum(page.hub**2 for _, page in pages.items()) summed_auth = sum(page.authority**2 for _, page in pages.items()) for _, page in pages.items(): - page.hub /= summed_hub - page.authority /= summed_auth + page.hub /= summed_hub**0.5 + page.authority /= summed_auth**0.5 class ConvergenceDetector(object): diff --git a/tests/test_nlp.py b/tests/test_nlp.py index 43f71f163..3dc5a57aa 100644 --- a/tests/test_nlp.py +++ b/tests/test_nlp.py @@ -95,7 +95,7 @@ def test_relevant_pages(): def test_normalize(): normalize(pageDict) print(page.hub for addr, page in nlp.pagesIndex.items()) - expected_hub = [1/91, 2/91, 3/91, 4/91, 5/91, 6/91] # Works only for sample data above + 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 expected_auth = list(reversed(expected_hub)) assert len(expected_hub) == len(expected_auth) == len(nlp.pagesIndex) assert expected_hub == [page.hub for addr, page in sorted(nlp.pagesIndex.items())]