Text this: Approximate counting, the Lovasz local lemma, and inference in graphical models