Text this: Purification of a single-photon nonlinearity