Algorithm for shortening similar words