It's called "sentiment analysis", and it's a very well developped and commercialized part of AI.
And of course, text generator use it to choose words according to the conoted emotional load, according to the goal set by the emotional branding.
70% of twitter traffic is generated automatically by such systems, working for the US military and corporations.
http://www.pnas.org/content/111/24/8788.full