So this was the last sprint day here at the snowsprint, and a lot of work was done to wrap-up some of the tasks. On my side I worked on two topics:
- adding a new describe command to zc.buildout
- coding a random-text generator library
Adding a “describe” command to zc.buildout
Godefroid came up with a nice idea about buildouts: when you are working with a recipe, it’s sometimes hard to figure out what are the options it takes, which ones are optionals, what are the default, etc.
It means that you have to digg into the code, or get to the PyPI page. Hopefully this page will give you the infos, if the long_description variable was hooked into some reSTructuredText. (see iw.recipe.pound for example).
That make a lot of context changes for the developer, so basically, the idea of the new describe command is to be able to query for a given recipe help. This help will be displayed online as long as the recipe creator fills the Recipe class docstring. We checked with Jim that this would be a good idea, since he wants (and that’s good) to keep the recipe as simple as possible (basically, any class with an install and an update commands). Since he liked the idea, we started to code it.
So basically, the command is called like this:
$ bin/buildout describe my.recipes
my.recipes
The coolest recipe on Earth.
Ever.
It deals with recipe versions and takes care of multiple entry points:
$ bin/buildout describe my.recipes:default my.recipes:second
my.recipes:default
The coolest recipe on Earth.
Ever.
my.recipes:second
No description available
This feature looks quite simple, but was a bit tricky to implement, since we had to parse the working set of the current buildout to extract the infos. The version section is also taken care of.
All that work we did together with Godefroid and Dokai is in a branch, waiting for Jim’s feedback.
Coding a random-text generator
When we worked on benchmarking Solr versus Plain catalog on the indexing task, we created a small script to generate random text, based on a chomsky algorithm. We were really excited about going deeper in this topic. Both Dokai and I worked on some generators. I have written on my side a Python port of nonsense, and the results were pretty interesting.
Anyway, we started a fun task for the last day with Dokai and Ethan: write a random-text generator library and a grok-based web app on the top of it. I worked on the core part, and we came up with this cool command line scripts that would generate som random text, given a file that would provide structure of sentences, and for each part of the sentence a list of choices.
The command is building the sentences picking the choices randomly. For example this file adapted from nonsense (extract):
[gibberish]
default =
${course}
name = college
annoucement =
The ${university} class "${course}" has been cancelled due to lack of interest.
Starting next year, incoming freshman at ${university} will be required to take "${course}."
"${course}" will no longer be offered at ${university} due to lack of interest.
Due to overwhelming popularity, an additional section of "${course}" will be offered at ${university} next semester.
Not one single student signed up for ${university}'s "${course}" last semester.
course =
${adjective} ${noun} ${suffix}
${adjective} ${noun}: ${ending}
${adjective} ${noun} And ${adjective} ${noun} ${suffix}
${noun} & ${noun} ${suffix}
${group1} ${group2} ${life} ${suffix}
${group2} ${noun} ${life} ${suffix}
${group1} ${group2} ${life} Since {#1800-1970}
${group2} ${life}: ${ending}
event =
The African Diaspora
The Harlem Renaissance
The Civil Rights Movement
The Italian Renaissance
Westward Expansion
Manifest Destiny
Women's Suffrage
World War I
World War II
The War Of 1812
The American Revolution
The French Revolution
The Russian Revolution
The American Civil War
The Spanish-American War
The Franco-Prussian War
The JFK Assasination
action =
Basketweaving
Aquatic Ballet
Synchronized Swimming
Professional Sports
The ${adjective} Pottery Experience
Home Economics
Cardplaying
Birdwatching
noun =
Diversity
Globalism
...
will generate random, domain-specific text. A Grok application has been built on the top on this, allowing dynamic creation of such files, and online text generation. Check out Dokai’s blog about this during the week, as he will present the Grok part. The code is in a Git repo here: http://repo.or.cz/w/gibberis.ch.git
Thank you Lovely Systems
Thanks to the Lovely team for this sprint !
Hey Tarek, just wanted to let you know I’ve taken the liberty of uploading gibberisch to pypi. (It was the easiest way to get it to another computer to do a presentation the other day.) Hope you don’t mind, and let me know if you want to become an owner. I may also put it in an SVN repository somewhere as well as the git repo.. maybe then you can actually commit to it
@Ethan: Hey ! Sure that’s pretty cool, my pypi user is Tarek. I wouldn’t mind having a svn too, since Linus doesn’t want me to commit
. Take care.
[...] idea of creating a library for generating random text based on context-free grammars. You can read Tarek’s post on the library for more information. The end result was that we created a project on [...]
Where can I find the python source code for your random text generator?
Hi!
I am a new python user. Is there a way that you could teach us how to use Gibberisch?
How can I load the text and is there a way to change the list of words?
Thank you!
@Ralph: http://repo.or.cz/w/gibberis.ch.git
@Arnold: It’s not hard. Pick up the code, and see how it works. You can load your own words list of course.