ruby implementation of disambiguation module