Word ranking algorithm