Text this: A reduction algorithm for cosmological correlators