To display a comment section on any publishing page, you can simply add a noteboard web part on the page or follow this article to add a social comment control on the page layout. In the article, author also talked about how to add the rating functionality.
Amol Meshe summarised a few points about the noteboard web part here.
- In order to use noteboard, User Profile service application needs to be associated with your web application.
- Number of replies to display can be configured via Note Board web part properties.
- Notes goes in the same DB and mapped against the page url.
Found this article that explains how to display comments count using DVWP and SOAP services.
These links talks about how to use code to get comment counts