View Full Version : anyone use python? I need a hand to hold....

05-07-2011, 08:29 PM


06-07-2011, 09:13 AM
A bit, yeah.

What's the problem?

06-07-2011, 10:50 AM
well at first I was using a 34/64 bit version that wasn't working with my mac - caused a headache.... kept crashing

so now im running regular 32 bit. - all good...

a few of the commands are coming to me, I figured out how to make a random two word phrase from 2 sets of multiple words.....so that's cool... but I'm trying to make a sentence generator..... so tips on how to achieve this in a newbie freindly prose would be cool.... I really dont know the first thing so need a little help, but at the same time, this is an ends to a means, I dont want to be a programmer...

06-07-2011, 11:04 AM
Why python? I don't really know much python, but I am a programmer (use Ruby, it's well better, and your Mac already has it installed), so I could probably knock something together. How would a sentence generator work? Would it need to be grammatically correct? You could do something like 'random pronoun from a list' 'random verb from a list' the 'random noun from a list' (he hit the dog, they ate the computer, etc, etc) really easily, but getting more flexible than that would quickly become a pretty tricky problem. You'd have to encode all kinds of lexical rules on sentence structure, which is decidedly non-trivial even to describe, let alone program.

If you can post a step by step process of how you'd like it to work that would help.

06-07-2011, 11:12 AM
The standard online tutorial is well written and very good -
Sections 1 to 5 cover everything you need to know to basically get the job done, although if you're going to do a bigger project or something that will have to deal with the real world it's maybe worth learning to do stuff like exception handling as well.

I find that searching Stack Overflow is quite good for dealing with common "how do I make it do this" or "what's the best way to do that" problems.

For serious natural language stuff, the Natural Language Tool Kit is brilliant (and free):
That site includes a book about how to use the NLTK which is written for non-programmers, so it takes you through language features as well as the NLTK package itself...

06-07-2011, 11:29 AM
slothrop - those links look good, will spend some time on them later, thanks...

I dont want gobbledygook, I want pseudo believable, agressively acadmic prose, so rules like a verbified version of a previous sentences word every 5 lines would be nice..... but grammatically correct ( well, maybe not but readable and natural ) - so maybe working randomly from a set list of sentence structures, that have set lists of possible words..... within which affects the outcome of further random words as the sentence progresses? As I'm new to this it's beyond my grasp technically, so learning the tools to do this really what I am after...

I also wonder if you could take this meta and assign ( like in html text ) a set of web pages that various words could randomly work through linking..... so each partcular verbification has x3 possible links.....

if you ever see my posts elsewhere round here you may get an idea of what I am trying to semi-automate


"There is, unfortunately, an essential demonic entity activated within, or rather at the core of, my endologix ( centrus-demonix, or perhaps daemonumbilicus?? ). For whilst intrinsic negativism is a component of many lucrative and engaging militant dysphoria within academic realms my particular woe(s) supersedes engagement, academic interests and oblique tangents of influence. Whilst many vectors of catalism, coagulation and conflux can thrive a la sub-dysphoria habitats my specific ontology expends massive energies upon auto-querious avenues as opposed to pro-exterior, extroverted modes of psycho-mechanisations.... This auto-phagic formatting of interior questioning is essentially preceding, or substituting all further thoughts and exo-contextual analysis.

EDIT - simultaneously there is an endogenically propelled exo-pursuit to discover xeno-medicinal properties within texts. A voracious chasing of an undiscovered cure.... So whilst cerebral experience is undiminished and perhaps, questionably, growing - the belief, the ontological foundation, (sub-ontologix psychosphere) is still co-existing beneath the noumenon of auto-phagic inontologies.....
Last edited by you; 17-06-2011 at 10:55 PM. Reason: oenologix "

06-07-2011, 11:42 AM
Some form of generative grammar is probably what you want:

I don't think there's a vast body of knowledge about how to do exactly what you're doing - most research is into how to effectively communicate an abstract representation of some information in natural sounding language - so you're probably just going to have to hack around with different ad hoc methods until you get something that works.

Particularly if you're going to be doing a lot of hacking and prototyping and experimenting, it's really important to break your code down into self contained functions with clearly defined tasks, cos it makes it a lot easier to go and say "hey, why don't I try doing X like I was doing before but when it used to do Y have it do Z instead," and when you come back to your code later you see a function called "do_x" rather than a load of impenetrable low level code. Someone once told me to aim for four lines of code per function, which is a bit extreme but gives some idea of how much it's possible to break stuff down.

Mr. Tea
06-07-2011, 11:58 AM
A timely post, for me - I just downloaded the Python interpreter with the numpy and scipy extensions in an attempt to make myself more employable - haven't really started on it yet but intend do over the next couple of weeks. May well be asking peeps on here for advice. Nice one, You!

07-07-2011, 09:18 PM
my uncanny cephalapod maybe myriad . both uncanny anthropod maybe uncanny , some infinite dust maybe myriad . both infinite anthropod might infinite , which voracious dust is infinite , both voracious mould maybe multiple , my multiple tome maybe multiple . many multiple collision is infinite . my unknown tome maybe voracious . which infinite cephalapod might uncanny . all endless dust maybe voracious . both vicious text might endless , my unknown text is poly-propagating , both poly-propagating mould maybe vicious . which voracious dust might endless , all myriad oil maybe myriad , many multiple collision might uncanny , some multiple collision maybe uncanny . many multiple text maybe myriad , many infinite oil maybe poly-propagating , my poly-propagating text is voracious , which uncanny oil might multiple . many uncanny oil might unknown . a infinite dust might endless . both multiple text is poly-propagating , a poly-propagating cephalapod is vicious . which vicious dust is infinite . both poly-propagating text maybe uncanny , both multiple oil might uncanny . both endless cephalapod might endless . which vicious dust is voracious . a multiple dust maybe endless . some uncanny collision is unknown , some multiple tome maybe infinite . my uncanny collision is voracious , many poly-propagating cephalapod might myriad , a myriad text is unknown . both multiple anthropod might endless . both multiple text might voracious ,
<iframe width="640" height="510" src="http://www.youtube.com/embed/QwWLU9SBFNo?rel=0" frameborder="0" allowfullscreen></iframe>

08-07-2011, 10:00 PM
well, I've managed to make a set of real sensical sentences, consistently - not a single one of them fails, so that's cool, python has helped! I I expect i'll still be hankering for advice as my odd little project progresses though. In the meantime i'll be posting my shit on my old fiction bias blog Pyrrhic Victories Against Urban Oncostrophy (http://pyrrhicvictoriesagainst.blogspot.com/) ( yeah! Catch-y! )

Just thought I'd chime in to say thanks, and also direct anyone who may be interested to where my thoughts might progress - rather than dump another load of text again.

11-07-2011, 09:53 AM
I used Python for a lot of natural language stuff a couple of years ago for my Master's - it's definitely a good language to choose for it (the other good one being Perl, but you don't get much for it's added complexity).

Can also vouch for NLTK and its O'Reilly book (http://oreilly.com/catalog/9780596516499) - very powerful starting points.