Hierarchical clustering algorithms in the psychology of grammar