From 8777ee7f3375bebd8f07ea033657c8260e7e19a3 Mon Sep 17 00:00:00 2001 From: Chipe1 Date: Thu, 30 Mar 2017 01:30:55 +0530 Subject: [PATCH 1/2] Fixed normalize() --- nlp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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): From 2ef0faae0aa5d236069f28f0717bcc39541eaea6 Mon Sep 17 00:00:00 2001 From: Chipe1 Date: Thu, 30 Mar 2017 01:32:25 +0530 Subject: [PATCH 2/2] Update test for normalize() --- tests/test_nlp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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())]