Learning to Substitute Spans towards Improving Compositional Generalization