Understanding and Mitigating Spurious Correlations in Text Classification with Neighborhood Analysis