Variational learning frameworks for generative models based on hierarchical Dirichlet and Pitman-Yor processes