Generating coherent and contextually relevant text