Files
tilde-projects/Code/irc/madlibbot/madlib.pyc
T

13 lines
3.7 KiB
Plaintext
Raw Normal View History

2018-06-13 14:34:23 +00:00
ó
 [c@s¼ddlZddlZddlZdZejdƒZejdƒZd„Zded„Z d„Z
d „Z ed
„Z d „Z
d „Zd
„Zd„Zedkr¸eƒndS(iÿÿÿÿNs/home/*/madlibs/*.madlibs ^/home/(.*?)/.*/([^/]*)\.madlib$s {{(.*?)}}cCs^tjt|ƒ}t|ƒ}d|jdƒjddƒd|jdƒ|jdƒ|fS(Nt'it_t s' by ~ii(tretmatcht
file_regextcount_words_filetgrouptreplace(t file_nameRtcount((s*/home/krowbar/Code/irc/madlibbot/madlib.pyt munge_story s içcCs_tjtƒ}|tkrHtj|tdt|t|ƒƒƒƒ}n
|| }tt |ƒS(Ni(
tglobt file_patterntTruetrandomtsampletmaxtmintlentmapR (tlimittshuffletfiles((s*/home/krowbar/Code/irc/madlibbot/madlib.pyt find_storiess
 -
cCsttj|ƒƒS(N(Rt
word_regextfindall(tstory((s*/home/krowbar/Code/irc/madlibbot/madlib.pyt count_wordsscCs2t|dƒ�}|jƒ}t|ƒSWdQXdS(Ntr(topentreadR(t storyPatht storyFileR((s*/home/krowbar/Code/irc/madlibbot/madlib.pyRs cCsottj|ƒƒ}t|ƒdkr+dS|d}|tkrStj|ƒ}n|jdƒ|jdƒfS(Nii( tlistRtfinditerRtNoneRRtchoiceR(RtrandtmatchesR((s*/home/krowbar/Code/irc/madlibbot/madlib.pytfind_next_word&s
 cCs|j||dƒS(Ni(R(Rtquerytword((s*/home/krowbar/Code/irc/madlibbot/madlib.pyt replace_word1sccsíg}d}xÌ|jƒD]¾}x]t|ƒ|kr~||d}|j|| dƒdj|ƒVg}d}||}q"W|t|ƒd|kr¶dj|ƒVg}d}n|j|ƒ|t|ƒd7}qWdj|ƒVdS(Niit-R(tsplitRtappendtjoin(tlinetmax_sizetwordst words_lengthR*t splitsize((s*/home/krowbar/Code/irc/madlibbot/madlib.pyt yield_lines6s"