Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed normalize() #439

Merged
merged 2 commits into from
Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_nlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())]
Expand Down