Git Product home page Git Product logo

poetry-generator's Introduction

A Python2 based Backus-Naur poetry generator.

This program works on the basis that every word in the English language is either "positive" or "negative." For instance "lovely" is positive and "thorn" is negative. A "poem" is a group of sentences that are structured in a way to have +1, -1 or 0 in terms of the positivity/negativity. A "mushy poem" is strictly positive.

All the syntax and word choices are in the brain.yaml file (more info about this below).

Try the demo here.

Docker

$ docker run -p 8000:8000 schollz/poetry-generator

Now open your browser to localhost:8000!

Changes in new version

  • Use YAML
  • Reverted to Python2 (to use Nodebox Linguistics)
  • Use Nodebox Linguistics for plurality and conjugations (saves much space)
  • Poem dictation (Chrome only)

Setup

Follow these commands to generate a poem if you have minimal experience coding/etc. Open up a terminal and use

git clone https://github.com/schollz/poetry-generator.git
cd poetry-generator

Install Python requirements

pip install -r requirements.txt

Download and unzip the NodeBox linguistics package:

wget https://www.nodebox.net/code/data/media/linguistics.zip
unzip linguistics.zip

And then run using

waitress-serve --port=8000 poetrygenerator:application

Then open your browser to localhost:8000 to see the poetry generator.

About the brain file

Examples of the types of words:

verb-pr = hopes
verb-past = hoped
verb = hope
verb-inf = hoping

Currently you only need to put in the infinitive form, and the other forms will be determined automaticlaly.

Deployment

I wrote a deployment script for easy NGINX deployment (keep reading). This will install NGINX blocks, as well as a Linux init.d script to automatically start and stop gunicorn.

Edit deploy.py to change

APP_NAME = 'poetry-generator'
APP_URL = 'www.poetrygenerator.ninja'
APP_PORT = 8002

or leave the same - its up to you.

Then run

sudo python deploy.py install

This program now uses virtualenv so it can be deployed with gunicorn. The installation creates virtualenv and downloads the packages. Then it writes a new init.d script and sends that so that it can automatically start and stop. If you deploy, it will also generate a nginx server block so its already to go.

The program should be running and accessible on your LAN network at

YOURLOCALIP:8002/

Common Error

When you run, you may see the following error:

[....] Reloading nginx configuration (via systemctl): nginx.serviceJob for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details.
 failed!

To fix this, you just need to enable the server_names in nginx. First

sudo vim /etc/nginx/nginx.conf

And uncomment these lines:

server_names_hash_bucket_size 64;
server_name_in_redirect off;

and now you should be good to go!

Credits

Thanks to nylen for greatly improving Poetry Generator, by fixing code and adding permalinks to poems!

poetry-generator's People

Contributors

nylen avatar schollz 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  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  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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

poetry-generator's Issues

Missing " in poetrygenerator.py

When referencing jQuery you have the following:

<script src=https://code.jquery.com/jquery-1.12.0.min.js"></script>

This causes an error where jQuery is undefined.

It should be <script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>

License missing

Assume it's something like MIT?
Not defined in the project or files.

pip install -r requirements.txt throws error

» pip install -r requirements.txt

  Using cached waitress-1.0.2-py2.py3-none-any.whl
Collecting pyyaml (from -r requirements.txt (line 2))
  Using cached PyYAML-3.12.tar.gz
Installing collected packages: waitress, pyyaml
Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/Library/Python/2.7/site-packages/pip/wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/waitress'

Nodebox Linguistic file is missing

I guess nodebox updated, and I can't find the linguistics zip file anymore. Can anyone be kind enough to update the instructions and/or upload the file somewhere?

Thanks

comments

very good project but you can add some comments to your code

"bad module?"

Having this weird issue
Error: Bad module 'poetrygenerator' upon running waitress-serve --port=8000 poetrygenerator:application

Any idea what could cause this?

Figured it out, closing.

BNF generator from poetry corpus

I'd like to be use a corpus of poetry to generate a new BNF brain. I think this can be done using NLTK and NodeBox::Linguistics to parse sentences and generate their BNF divisions and determine their tenses.

Working for v1.1

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.