Skip to content

Commit 85e69a3

Browse files
AITweetGenerator v1.0
1 parent c8ccbe6 commit 85e69a3

File tree

4 files changed

+607
-2
lines changed

4 files changed

+607
-2
lines changed

README.md

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
1-
# AITweetGenerator
2-
An AI based tweet generator which can generate collection of tweets automatically
1+
# AITweetGenerator by Tiancheng (Joseph) Zheng
2+
3+
## Description
4+
An AI based tweet generator which can generate collection of tweets automatically. It can be used to replace the usernames and texts of the real twitter data provided by the user with fake generated usernames and texts. The tweets are generated using models learned from real tweets using the `textgenrnn` library.
5+
6+
## Prerequisites
7+
### Libraries
8+
- `textgenrnn`, which can be installed using `pip install textgenrnn`
9+
- `ujson`, which can be installed using `pip install ujson`
10+
- `tensorflow`, which can be installed using `pip install tensorflow`
11+
- If other libraries are missing, install them using `pip install <library>`
12+
### Data
13+
Users must provide the raw twitter data downloaded from Twitter, which will be fed to both the trainer and the generator.
14+
### Python Version
15+
Python version must be at least Python 3.6.
16+
17+
## Pipeline
18+
0. IMPORTANT: create a subdirectory called `weights` in the same directory as the scripts for the pipeline to work.
19+
1. Run `tweet_trainer.py` to train a model using the `textgenrnn` library. It trains the model using a sample of size `k` from the json file containing the raw twitter data, which is provided by the user. It takes three parameters: `-i` -- the json file storing the original tweets (e.g. `tweets.json`), `-k` -- the training sample size, and `-e` -- the training epoch. An example is `python3 tweet_trainer.py -i tweets.json -k 20000 -e 5`. Please use `python3 tweet_trainer.py --help` for a detailed description of the script and its parameters.
20+
2. Run `tweet_generator.py` to replace tweets with fake usernames and texts. The fake usernames are generated by the helper function `name_generator.py`, and the fake texts are generated using the trained model. The script generates the tweets and writes them into another json file in batches of size `k`, which is specified by the user. It takes three parameters: `-i` -- the json file storing the original tweets (e.g. `tweets.json`), `-o` -- the json file to store the fake tweets (e.g. `fake_tweets.json`), and `-k` -- the batch size to generate. An example is `python3 text_generator.py -i tweets.json -o fake_tweets.json -k 12000`. Please use `python3 text_generator.py --help` for a detailed description of the script and its parameters.
21+
22+
## Appendix
23+
### Relevant Scripts
24+
1. name_generator.py
25+
2. tweet_trainer.py
26+
3. tweet_generator.py

0 commit comments

Comments
 (0)