If you are analysing your facebook messages, first you have to download this addon https://chrome.google.com/webstore/detail/counter-for-messenger/flkejcheidpcclcdokndihmnlejfabil and download the messages. Then unzip the file and get the messages by Scaper.py file, it will give you a csv file of messages. you can then run Facebook_mesg file to analyze your messages.
If you are analysing whatsapp messages, export your whatsapp chat and run the Whatsapp_mesg to analyze your messages.