Skip to main content

pytwanalysis - (Twitter Analysis)

A tool to gather, discover, and analyze Twitter data using a combination of graph-clustering and topic modeling techniques with the goal of semantically grouping tweet messages together.

Installation

pip install pytwanalysis

Initializing an object

import pytwanalysis as ta
#set up your mongoDB connection here
mongoDBConnectionSTR = "mongodb://localhost:27017"
client = MongoClient(mongoDBConnectionSTR)
db = client.yourDB #chose your DB name here
BASE_PATH = '[youFolderPath]' #path where you want to save your files
x = ta.TwitterAnalysis(BASE_PATH, db)

Requirements:

  1. Python 3.7

  2. Database: MongoDB - (Version: 4.0+)

  3. Libraries:

  • pymongo
  • NLTK
  • numpy
  • networkx 2.3
  • matplotlib 3.2.1
  • gensim
  • sklearn
  • python-louvain
  • scipy
  • seaborn
  • pandas
  • wordcloud
  • Pyphen
Pre-requisites installation
 pip install pymongo
 pip install nltk
 pip install numpy
 pip install networkx==2.3
 pip install matplotlib==3.2.1
 pip install gensim
 pip install -U scikit-learn 
 pip install python-louvain 
 pip install scipy 
 pip install seaborn 
 pip install pandas 
 pip install wordcloud
 pip install Pyphen

Things you can do with this library:

  • Use mongoDB to store and process your Twitter data
  • Export edges created based on user connections
  • create graphs, timeseries analysis, topic analysis, and graph analysis of you Twitter data
  • create folder structure to save all files (by period or not)
  • create the following files for each folder and sub folder
    • nodes with degrees
    • edges
    • texts for topics
    • graph with lda model
    • graph plot
    • graph plot with contracted nodes
    • hashtag & words frequency list
    • hashtags & words barChart
    • timeseries plot (tweet count & hashtag count(
    • wordclouds (high degree nodes, high frequency hashtags, high frequency words)

Data Management with mongoDB:

  • load json twitter files into mongoDB

    *The logic is setup so that you can run the same file multiple times. It won't load the same file twice. And if something fails, it starts from where it stopped.

  • create aggreation collections with data for EDA (e.g. tweetCountByFile, hashtagCount, tweetCountByLanguageAgg, tweetCountByPeriodAgg, tweetCountByUser)

  • break text into words

  • create collection with hashtags for each tweet

  • create collection with edges between users formed by replies, retweets, quotes and mentions

  • create collection with users info

  • export data into \t delimeted files that can be opened as CSV files

  • run different topic model analysis for hashtags groups

Graph Analysis

  • load a networkx file from node/edge files
  • print measurements from graph (Diameter, Radius, Extrema bounding, Centers with their degree, # Nodes, # Edges)
  • plot graph
  • plot graph with clusters (spectral clustering / Louvain Community)
  • contract nodes

Topic Analysis

  • train topic model
  • plot topic distribution
  • plot frequency lists (hashtags, word frequency)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytwanalysis-0.0.2.tar.gz (44.1 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pytwanalysis-0.0.4-py3-none-any.whl (60.6 kB view details)

Uploaded Python 3

pytwanalysis-0.0.3-py3-none-any.whl (57.5 kB view details)

Uploaded Python 3

File details

Details for the file pytwanalysis-0.0.2.tar.gz.

File metadata

  • Download URL: pytwanalysis-0.0.2.tar.gz
  • Upload date:
  • Size: 44.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for pytwanalysis-0.0.2.tar.gz
Algorithm Hash digest
SHA256 34b12a2aa834c027cd3c01a140b2e243bcd581502e19c946bdac7e9e2adb23cf
MD5 c00302155651b0e3ad8456be070d9a9b
BLAKE2b-256 65d9e97dd52d6b2de4a1caebd722472234f332261f81fb07d0b83ce61a5ad29d

See more details on using hashes here.

File details

Details for the file pytwanalysis-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: pytwanalysis-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 60.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for pytwanalysis-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4970909f3bf5ff22ba148c017fbc74a1b7960ea35044ae468644c3f2656c8c5d
MD5 91f67facaf8a85525f8dbd71c6636f1c
BLAKE2b-256 27985e326baf78143142ad9a8df4e869ea71493e80ad00499a833e2a99e76a7d

See more details on using hashes here.

File details

Details for the file pytwanalysis-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pytwanalysis-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 57.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7

File hashes

Hashes for pytwanalysis-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0fe4996ddfa5e17a7aacaa785d2bfb3c9d1e7f8aeddfcc83637656f7c0d9b42d
MD5 5f7ff7eee101574e8a592e2372c3a8a4
BLAKE2b-256 9bd08ebe37d5e9d03c20464b752f6cd52acc1e72765a3b73c464e803c007646e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page