klittlepage / chatty

Chatty: analyze texts to/from your friends

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introduction

Curious about the texting habits of you and your friends? Look no further! Chatty will show you stats on how you communicate with whatever individual you tell it to analyze. Out of the box, Chatty supports iMessage, WhatsApp, and Line. Custom sources and arbitrary text is supported as well.

Why?

Why not? Texting styles are a hot topic of discussion in my friend group. I wanted quantitative evidence that some of my friends are better texters than others. Kidding. Kind of.

Preview

Please see the project notebook for a full demonstration. Note that GitHub does not render Jupyter notebooks on mobile. If you "Request as Desktop Site" using your mobile broswer, it's still fairly readable.

Short of that, two examples (out of the many in the notebook) are a comparison table generated by summary_comparison:

Metric From Me To Me
Message Count 1,199 960
Word Count 29,686 14,243
Avg Message Word Count 24.76 14.84
Avg Message Word Count (w/o Stop Words) 14.48 9.36
Avg Message Character Count 96.38 55.48
Avg Message Character Count (w/o Stop Words) 68.51 41.03
Longest Message 208 91
Distinct Words 4,345 2,631
Distinct Stems 3,438 2,229
Distinct English Words 3,773 2,248
Distinct Emojis 38 32
Emoji Count 193 118
Pct Negative Sentiment 7% 4%
Pct Positive Sentiment 18% 19%

and sentiment analysis carried out and displayed by sentiment and sentiment_plot:

Distribution of message sentiments sent and received

Installation

A working Python 3 Anaconda environment is required. Once Anaconda is installed, run:

conda env create -f environment.yml

to install Chatty's dependencies.

Running

Launch chatty by running:

source activate chatty
jupyter notebook

Select a source per the instructions below, and re-evaluate all cells.

External Variables

Chatty includes a utility for reading config from an external yaml file: chatty.load_vars(vars_file='vars.yml'). Use this method for situations where you wish to share your notebook without exposing sensitive variables (e.g. names or telephone numbers).

Sources

iMessage

The iMessage source requires an OSX computer with iMessage. Once the notebook loads, redefine RECIPIENT_ID to either an E.164 number of the form '+13031234567' or an iMessage handle of the form 'foo@bar.com'.

WhatsApp

The WhatsApp source reads from a WhatsApp chat log exported by the iOS WhatsApp client. It has not been tested against other clients.

from chatty.sources import whatsapp_chat

project_vars = load_vars()
all_messages = whatsapp_chat(project_vars['chat_path'])
from_messages = all_messages[project_vars['from']]
to_messages = all_messages[project_vars['to']]

Line

The line source reads from a Line chat log exported by the iOS Line client. It has not been tested against other clients.

from chatty.sources import line_chat

project_vars = load_vars()
all_messages = line_chat(project_vars['chat_path'])
from_messages = all_messages[project_vars['from']]
to_messages = all_messages[project_vars['to']]

Hacking

All analysis functions are composable and built for reuse. By default, Chatty will analyze messages sent to/from the counter party defined by RECIPIENT_ID. You can change this behavior by redefining from_messages and to_messages before the analysis functions are called.

Todo

  • Support other message sources
  • Add time series/trend analysis
  • PRs welcome

License

Chatty is released under the MIT License.

About

Chatty: analyze texts to/from your friends

License:MIT License


Languages

Language:Python 74.1%Language:Jupyter Notebook 25.9%