Package: chat-miner
chat-miner: turn your chats into artworkchat-minerprovides lean parsers for every major platform transforming chats into dataframes. Artistic visualizations allow you to explore your data and create artwork from your chats.1. InstallationLatest release including dependencies can be installed via PyPI:pipinstallchat-minerIf you're interested in contributing, running the latest source code, or just like to build everything yourself:gitclonehttps://github.com/joweich/chat-miner.gitcdchat-miner
pipinstall-rrequirements.txt2. Exporting chat logsHave a look at the official tutorials forWhatsApp,Signal,Telegram,Facebook Messenger, orInstagram Chatsto learn how to export chat logs for your platform.3. ParsingFollowing code showcases theWhatsAppParsermodule.
The usage ofSignalParser,TelegramJsonParser,FacebookMessengerParser, andInstagramJsonParserfollows the same pattern.fromchatminer.chatparsersimportWhatsAppParserparser=WhatsAppParser(FILEPATH)parser.parse_file()df=parser.parsed_messages.get_df(as_pandas=True)# as_pandas=False returns polars dataframeNote:Depending on your source system, Python requires to convert the filepath to a raw string.importosFILEPATH=r"C:\Users\Username\chat.txt"# WindowsFILEPATH="/home/username/chat.txt"# Unixassertos.path.isfile(FILEPATH)4. Visualizingimportchatminer.visualizationsasvisimportmatplotlib.pyplotasplt4.1 Heatmap: Message count per dayfig,ax=plt.subplots(2,1,figsize=(9,3))ax[0]=vis.calendar_heatmap(df,year=2020,cmap='Oranges',ax=ax[0])ax[1]=vis.calendar_heatmap(df,year=2021,linewidth=0,monthly_border=True,ax=ax[1])4.2 Sunburst: Message count per daytimefig,ax=plt.subplots(1,2,figsize=(7,3),subplot_kw={'projection':'polar'})ax[0]=vis.sunburst(df,highlight_max=True,isolines=[2500,5000],isolines_relative=False,ax=ax[0])ax[1]=vis.sunburst(df,highlight_max=False,isolines=[0.5,1],color='C1',ax=ax[1])4.3 Wordcloud: Word frequenciesfig,ax=plt.subplots(figsize=(8,3))stopwords=['these','are','stopwords']kwargs={"background_color":"white","width":800,"height":300,"max_words":500}ax=vis.wordcloud(df,ax=ax,stopwords=stopwords,**kwargs)4.4 Radarchart: Message count per weekdayifnotvis.is_radar_registered():vis.radar_factory(7,frame="polygon")fig,ax=plt.subplots(1,2,figsize=(7,3),subplot_kw={'projection':'radar'})ax[0]=vis.radar(df,ax=ax[0])ax[1]=vis.radar(df,ax=ax[1],color='C1',alpha=0)5. Natural Language Processing5.1 Add Sentimentfromchatminer.nlpimportadd_sentimentdf_sentiment=add_sentiment(df)5.2 Example Plot: Sentiment per Author in Groupchatdf_grouped=df_sentiment.groupby(['author','sentiment']).size().unstack(fill_value=0)ax=df_grouped.plot(kind='bar',stacked=True,figsize=(8,3))6. Command Line InterfaceThe CLI supports parsing chat logs into csv files.
As of now, youcan'tcreate visualizations from the CLI directly.Example usage:$chatminer-pwhatsapp-iexportfile.txt-ooutput.csvUsage guide:usage: chatminer [-h] [-p {whatsapp,instagram,facebook,signal,telegram}] [-i INPUT] [-o OUTPUT]

options:
  -h, --help 
                        Show this help message and exit
  -p {whatsapp,instagram,facebook,signal,telegram}, --parser {whatsapp,instagram,facebook,signal,telegram}
                        The platform from which the chats are imported
  -i INPUT, --input INPUT
                        Input file to be processed
  -o OUTPUT, --output OUTPUT
                        Output file for the results