This is the source code resulting from Make School's CS 1.2 Class' Tweet Generator tutorial.
Some code requires the system to be UNIX-based (such as MacOS) as it reads from /usr/share/dict/words
.
These are in reverse order to show most recent developments.
It can be any article, book, blog, etc.
-
Convert your corpus to at text file.
-
Clean it - remove anything that's not part of the narrative.
-
Place it in texts as
corpus.txt
.
Not Done.
A HashTable
class implemented using a LinkedList
.
A LinkedList
class implemented using Node
objects.
Run python3 markov.py -h
for explanation.
Improved app.py
implementation.
A Histogram
implemented using a list
.
Run python3 dictogram.py
by itself or with a list of space-separated words.
A Histogram
class implemented using a dict
Run python3 dictogram.py
by itself or with a list of space-separated words.
This is the web app for the markov chain.
-
Install Flask and python-dotenv (preferably to a virtualenv)
-
Create a
.env
file with
FLASK_APP=app.py
FLASK_RUN_PORT=[your port]
FLASK_ENV=development
Read more on what you can do in Flask's documentation.
-
Run
flask run
-
Navigate to
localhost:[your port]
in your browser.
This will generate psuedo-sentence based on the corpus, refresh for different sentences.
This was my initial histogram sampling. It emulates random.choices
as we weren't allowed to use that built-in method.
python3 sample.py [words]
where [words]
is a list of space-separated words.
A Histogram
implemented using with a dict
, list
of list
s, or list
of tuple
s.
Improved anagram.py.
Generates a list of words that could complete the provided word.
Run python3 autocomplete.py [word]
.
[word]
= a single word.
Reads from /usr/share/dict/words
and generates a list of random words from it.
Generates a list anagrams of a provided word.
Run python3 anagram.py [word]
[word]
= a single word.
Reverses words or the order of words in sentences.
Shuffles the provided list.
- = requires UNIX-based system such as Ubuntu or MacOS.