lundi 14 décembre 2015

Generating random comments with python from a text source

I read on wikipedia about Article spinning and I'm trying to create a function that does the same thing from a text source.

For example a text source could be:

{Hello|Hi|Howdy}{ ,I {really like|absolutely adore} your {picture|media|upload}|{, how are you?|, are you ok?}}

Some of the random comments that can be generated:

Hello, I really like your picture
Hi, I absolutely adore your upload
Hi, how are you?
and so on...

My main problem is reading the words between brackets. I'm currently using a text regex but python is only considering the first and the last bracket, so that's what I'm getting:

Hello|Hi|Howdy}{ ,I {really like|absolutely adore} your {picture|media|upload}|{, how are you?|, are you ok?}




Aucun commentaire:

Enregistrer un commentaire