Skip to content

Instantly share code, notes, and snippets.

@bgschiller
Last active October 4, 2017 22:32
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgschiller/352d1169b4a39819db3fd2e99c9208b2 to your computer and use it in GitHub Desktop.
Save bgschiller/352d1169b4a39819db3fd2e99c9208b2 to your computer and use it in GitHub Desktop.

Install postgresql

(The best SQL database)

Mac:

Best bet is to use http://postgresapp.com/ .

Make sure to set up your path once it's installed:

  1. Run atom ~/.bash_profile.
  2. Add the line export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin
  3. Save and close the file.

Windows:

Download the installer from http://www.enterprisedb.com/products-services-training/pgdownload#windows and run it. I don't have a Windows machine, so please comment here if you have more guidance.

Linux:

Use your distro's package manager to install postgres.

Create a prosaic user and db

At a terminal prompt, run createuser prosaic and then createdb prosaic. This is the default location where prosaic stores snippets of text. If you're on a window's machine and this doesn't work, let me know and I'll figure out what the right thing to do is.

Install the prosaic python package

pip is the python package manager (meaning: it's how we download and share libraries that don't come pre-installed). Run python3 -m pip install prosaic to install prosaic.

Something went wrong with that!
  • Something sort of permission-denied error: On mac or linux you may need to prefix the command with sudo, so run sudo python3 -m pip install prosaic.
  • On a Mac: "something something requires the command line developer tools". Go ahead and install them. It may take a while to download, because they're about 130MB.

More downloads!

Prosaic depends on nltk, the natural language toolkit, which in turn depends on some big files. They will download the first time you go to use it. Open up a python3 REPL and type import prosaic. This will kick off a large-ish download.

Wait! Survey the Scene.

Is everything working so far?

  • Running pg_config should print out a bunch of text:

  • Running prosaic --help at the command line should print out a message like this:

Running Prosaic

There's an official tutorial at https://github.com/nathanielksmith/prosaic/blob/master/doc/tutorial.md I ran into a couple issues that weren't addressed there, so I wrote the following.

Add your sources

I'm going to add the Mean Girls script. I'll make a file mean_girls.txt containing just the text I want. Then I run prosaic source new mean_girls mean_girls.txt.

For some reason, this is giving me an error:

There was an error extracting phrases:
********
4
********
The source 'mean_girls' was not saved.

But it seems to work, contrary to the message. ¯\_(ツ)_/¯ . I have a github issue about this at vilmibm/prosaic#36.

Add any other sources you might want.

Create a Corpus.

A corpus is (for prosaic) the combination of several text sources. This allows greater control for mixing and matching which sources being used.

prosaic corpus new my_first_corpus
prosaic corpus link mean_girls

link any other sources you want

Make a Poem

$ prosaic poem new --corpus my_first_corpus -t haiku # (t for 'template')

 Yeah, I'll be right back
 - North Shore, who do you select
 Great turnout this year

$ prosaic poem new --corpus mean_girls -t sonnet

 They're these weird Swedish nutrition bars
 Contestants, find the limit of this equation
 you're supposed to suck the poison out
 And a piece for Regina George

 Dude, put on The Ramayana Monkey Chant 
 you know what I mean
 There are gonna be girls there in their bathing suits
 Im doing major Plastic sabotage tonight

 You think that everybody is in love with you
 so don't bring some other guy with you
 I have her test results
 In January, Regina had put a Spring Fling dress on hold at a store called --

 From Marymount, Miss Caroline Krafft
 I was half a virgin when I met him

Other templates are available (run prosaic template ls to see a list). You can also write your own, which is covered in the official tutorial.

@shahnehashah2
Copy link

createuser and createdb do not work on my Windows machine. What could be my alternative?

@bgschiller
Copy link
Author

Harry and Ron jumped to their feet
And I'd be like, Why are you so obsessed with me
On Friday, no less than twelve letters arrived for Harry
I'm sorry that people are so jealous of me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment