Add per-doc topic distribution and unit test.