B x ̒^@s,dZGdddZddZedkr(edS)z1 Markov chain simulation of words or characters. c@s,eZdZddZddZddZddZd S) MarkovcCs||_||_i|_dS)N)histsizechoicetrans)selfrrr6/opt/alt/python37/lib64/python3.7/Tools/demo/markov.py__init__szMarkov.__init__cCs|j|g|dS)N)r setdefaultappend)rstatenextrrradd sz Markov.addcCsz|j}|j}|d|ddx}|t||kr,td}t|d!d'|t|d7}q WttqWdS)(NrrZ0123456789cdwqz"Usage: %s [-#] [-cddqw] [file] ...zOptions:z$-#: 1-digit history size (default 2)z-c: characters (default)z -w: wordsz-d: more debugging outputz-q: no debugging outputz3Input files (default stdin) are split in paragraphsz1separated blank lines and each paragraph is splitz0in words by whitespace, then reconcatenated withz#exactly one space separating words.z0Output consists of paragraphs separated by blankz4lines, where lines are no longer than 72 characters.Fz-0z-9z-cz-dz-qz-wT-zSorry, need stdin from filerZ processingz...z z feeding ... z-Interrupted -- continue with data read so farzNo valid input fileszdone.H)end)sysrandomgetoptargverrorprintexitintrrstdinisattyopenreadclosesplittuplejoinrKeyboardInterruptrkeysrreprr)r"r#r$argsZoptsrZdo_wordsdebugoamfilenameftextZparalistZparaZwordsdatakeyrlimitwrrrtest's                  rA__main__N)__doc__rrArrrrrs U