Fix the bug in computing weighted similarities.