Use markov chains to generate new posts titles in a subreddit
There is three scripts:
getPosts.jsgets the last posts from a given subreddit and save their titletrainMarkov.jsuses the titles to create a markov chaingenerateMarkov.jsuses the markov chain to generate new titles
All of the configurations are in the config.json file. Here is an example:
{
"SUBREDDIT": "showerthoughts",
"POSTS_FILE": "./data/posts/posts-showerthoughts.txt",
"COUNT": 10,
"ORDER": 2,
"MODEL_FILE": "./data/models/markov-showerthoughts-order2.json",
"DEVIATION_TARGET": 6,
"MAX_TRIES" : 100
}
SUBREDDITshould be a valid subreddit name without ther/COUNTis the number of page in the subreddit to getORDERis the size of the Ngrams used in the markov chainDEVIATION_TARGETis the minimum number of different branches in the markov chain the result should containMAX_TRIESlimits the number of tries to get toDEVIATION_TARGET
First clone the repo and install the dependencies
npm install
Tweak config.json as you want.
Get the posts with
node getPost.js
Generate a markov chain
node trainMarkov.js
You need to use this script each time you change the ORDER parameter.
Finally, generate a new title
node generateMarkov.js