Dimension reduction for exponential family data with applications to text data