Find a trending topic along the lines of #YinXwords and tweet a random X-word sentence from Project Gutenberg.
Python Batchfile Shell
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.coveragerc
.gitignore
.travis.yml
3-word-sentences.txt
4-word-sentences.txt
5-word-sentences.txt
6-word-sentences.txt
README.md
inxwords.py
inxwordsloop.bat
inxwordsloop.sh
requirements.txt
test_inxwords.py

README.md

@inXwords

Build Status Coverage Status

Find a trending topic along the lines of #YinXwords and tweet a random X-word sentence from Project Gutenberg.

See it in action at @inXwords and some of the best at http://favstar.fm/users/inXwords.

Inspired by Darius Kazemi's #FiveWordsToRuinADate, and GenGen, with which I made this prototype. I like that Darius's generators are powered by his gutencorpus, which was inspired by my gutengrep, and gutengrep is used here. Full circle!

Set up

First we need some lists of sentences from Project Gutenberg. For this I used a tool called gutengrep on the August 2003 CD ("contains 600 of our best Ebooks").

  1. Put all Gutenberg text files in the same directory and cd to it.
  2. gutengrep.py "^\w+\s\w+\s\w+[\.?\!]$" --cache > /tmp/3.txt
  3. edit /tmp/3.txt
  4. Edit out guff at start and end
  5. sort /tmp/3.txt | uniq > /tmp/3-word-sentences.txt
  6. Repeat for four, five and six-word sentences.
  7. wc -l /tmp/*.txt
   23949 /tmp/3-word-sentences.txt
   91551 /tmp/3.txt
   31396 /tmp/4-word-sentences.txt
  107418 /tmp/4.txt
   29835 /tmp/5-word-sentences.txt
   94720 /tmp/5.txt

8. Then create a new Twitter application, a new Twitter account, authorise them using this or that, fill in the keys in inxwords.yaml, and run something like:

python inxwords.py  --no-web --loop --yamp /path/to/inxwords.yaml --sendir /path/to/dir/of/gutenberg/sentences