generating corpus from database