From categories to edges: How diversity contributes to linguistic flexibility