Coder Social home page Coder Social logo

rsharifnasab / create_word_cloud Goto Github PK

View Code? Open in Web Editor NEW
26.0 26.0 6.0 5.58 MB

create word clouds with wrodcloud-fa for twitter and telegram chat

License: GNU General Public License v3.0

Python 100.00%
beautifulsoup python python3 telegram twint twitter worldcould

create_word_cloud's Introduction

create word clouds for telegram chat and twitter

how to use (general)

  1. read this file carefully

  2. open config.py and set your setting such as input address

  3. run program.py with python3.4 or higher

  4. select your context (twitter or telegram or normal text or twitter exported data)

  5. wait until the program finishes

how to use (tweets)

  1. you should get tweets from this site and paste to a file for example input.txt
  2. enter file address to config.py, twitter_config dictionary
  3. if you set 'SOURCE': "clipboard" program will use system clipboard instead of the input file
  4. you can set other options in that config
  • no_retweet and no_replis are work as they expected so
  • no link will remove all tweets contains links for example quotes, images and unfollow checker auto-tweets

how to use (telegram)

  1. export chat history to a folder
  2. enter folder address in config.py in telegram_config dictionary, something like './input/*.html'

how to use (twitter data)

  1. this option is for people who wants a cloud for all tweets not last 3000 tweets
  2. first of all, you should follow this link to export twitter data, it takes some time! be patient
  3. after your data is ready, download and unzip it, we need the tweet.js file in next step
  4. enter the path of tweet.js in the data folder to the config file (in config.py/data_config)
  5. open program and select option 4
  6. you can set NO_REPLIES if you want only your tweets not replies
  7. there is no NO_RETWEET option because retweets are not included in exported data
  8. Press enter and enjoy :D
  • no link will remove all tweets contains a link for example quotes, images and unfollow checker auto-tweets

notes

  • you can set font and mask in general_config file

    • enter a TTF font

    • mask image should be png or jpg

    • you don't need to specify file format! the program will guess it

  • if you use a third-party mask and its not black and white (greyscale for example) you can set NORMALIZE_MASK to True

  • normalize mask is a slow operation, it handles greyscale masks, if you use built-in masks you don't need it

  • if stop words didn't remove automatically, set STOP_WORD_CLEAN to "manual" in config.py

  • only if Persian words are reversed, make ARABIC_RESHAPER to True

  • line color and line width are for splitter line between text and whitespace, it may be good for some cases

  • max words and min font and max font are 3 numbers, change them with caution, if the min font is too low or max words is high, the whole operation will take much time if the max font is not so big, the cloud is ugly

Requirements

  • wordcloud
  • numpy and PIL
  • beautifulsoup4 (for parse telegram htmls)
  • arabic reshaper
  • bidi
  • clipboard

You can also install requirements using requirements.txt and pip:

pip3 install -r requirements.txt

to-do

  • write better documentation
  • add command-line argument parse
  • add well twint support for getting tweets automatically

special thanks to:

create_word_cloud's People

Contributors

dependabot[bot] avatar mo1ein avatar radinshayanfar avatar rsharifnasab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

create_word_cloud's Issues

there was problem during run abr.py

hi,i try to run abr.py in ubuntu 18.04 but this exception occurred:

Traceback (most recent call last):
  File "/home/sina/.local/lib/python3.6/site-packages/PIL/Image.py", line 2082, in save
    format = EXTENSION[ext]
KeyError: ''

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "abr.py", line 97, in <module>
    result_image.save(f"out/{idish}.png")
  File "/home/sina/.local/lib/python3.6/site-packages/PIL/Image.py", line 2084, in save
    raise ValueError("unknown file extension: {}".format(ext))
ValueError: unknown file extension: 

README.md

There are some grammatical mistakes in README.md file. Please use Grammarly or something else to fix it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.