Package: markovchain
OverviewMarkov chain generatorRequirementsPython 3Installationpipinstallmarkovchainpipinstallmarkovchain[image]gitclonehttps://github.com/dead-beef/markovchaincdmarkovchainpipinstall-e.[dev]Building./build.shTesting./testModule usageModule documentationExamplesTextfrommarkovchainimportJsonStoragefrommarkovchain.textimportMarkovText,ReplyModemarkov=MarkovText()withopen('data.txt')asfp:markov.data(fp.read())withopen('data2.txt')asfp:forlineinfp:markov.data(line,part=True)markov.data('',part=False)print(markov())print(markov(max_length=16,reply_to='sentence start',reply_mode=ReplyMode.END))markov.save('markov.json')markov=MarkovText.from_file('markov.json')ImagefromPILimportImagefrommarkovchainimportJsonStoragefrommarkovchain.imageimportMarkovImagemarkov=MarkovImage()markov.data(Image.open('input.png'))width=32height=16img=markov(width,height)withopen('output.png','wb')asfp:img.save(fp)markov.save('markov.json')markov=MarkovImage.from_file('markov.json')CLI usage> markovchain -h
usage: markovchain [-h] [-v] {text,image} ...

positional arguments:
  {text,image}

optional arguments:
  -h, --help     show this help message and exit
  -v, --version  show program's version number and exitData typesFile nameFile typeStorage classNone (stdout)JSONJsonStorage*.jsonJSONJsonStorage*.json.bz2bzip2 compressed JSONJsonStorageOtherSQLite 3 databaseSqliteStorageExamplesTextmarkovchaintextcreate--outputtext.dbinput1.txtinput2.txtmarkovchaintextupdatetext.dbinput3.txtinput4.txtmarkovchaintextgeneratetext.dbmarkovchaintextgenerate--count16--start'sentence start'text.dbImagemarkovchainimagecreate--progress--outputimg.dbimg1.pngimg2.pngmarkovchainimageupdate--progressimg.dbimg3.pngimg4.pngmarkovchainimagegenerate--progress--size6464--count4img.dbimg%02d.pngmarkovchainimagefilter--progressimg.pngoutput.pngSettingsTextImageText> markovchain text -h
usage: markovchain text [-h] {create,update,settings,generate} ...

positional arguments:
  {create,update,settings,generate}

optional arguments:
  -h, --help            show this help message and exitcreate> markovchain text create -h
usage: markovchain text create [-h] [-P] [-s SETTINGS] [-o OUTPUT]
                               [input [input ...]]

positional arguments:
  input                 input file (default: stdin)

optional arguments:
  -h, --help            show this help message and exit
  -P, --progress        show progress bar
  -s SETTINGS, --settings SETTINGS
                        settings json file
  -o OUTPUT, --output OUTPUT
                        output file (default: stdout)update> markovchain text update -h
usage: markovchain text update [-h] [-P] [-s SETTINGS] [-o OUTPUT]
                               state [input [input ...]]

positional arguments:
  state                 state file
  input                 input file (default: stdin)

optional arguments:
  -h, --help            show this help message and exit
  -P, --progress        show progress bar
  -s SETTINGS, --settings SETTINGS
                        settings json file
  -o OUTPUT, --output OUTPUT
                        output file (default: rewrite state file)generate> markovchain text generate -h
usage: markovchain text generate [-h] [-P] [-nf]
                                 [-s SETTINGS] [-ss STATE_SIZE]
                                 [-S START] [-E END] [-R REPLY]
                                 [-w WORDS] [-c COUNT] [-o OUTPUT]
                                 state

positional arguments:
  state                 state file

optional arguments:
  -h, --help            show this help message and exit
  -P, --progress        show progress bar
  -nf, --no-format      do not format text
  -s SETTINGS, --settings SETTINGS
                        settings json file
  -ss STATE_SIZE, --state-size STATE_SIZE
                        generator state size
  -S START, --start START
                        text start
  -E END, --end END     text end
  -R REPLY, --reply REPLY
                        reply to text
  -w WORDS, --words WORDS
                        max text size (default: 256)
  -c COUNT, --count COUNT
                        number of generated texts (default: 1)
  -o OUTPUT, --output OUTPUT
                    output file (default: stdout)settings> markovchain text settings -h
usage: markovchain text settings [-h] state

positional arguments:
  state       state file

optional arguments:
  -h, --help  show this help message and exitImage> markovchain image -h
usage: markovchain image [-h]
                         {create,update,settings,generate,filter} ...

positional arguments:
  {create,update,settings,generate,filter}

optional arguments:
  -h, --help            show this help message and exitcreate> markovchain image create -h
usage: markovchain image create [-h] [-P] [-s SETTINGS] [-o OUTPUT]
                                [input [input ...]]

positional arguments:
  input                 input file

optional arguments:
  -h, --help            show this help message and exit
  -P, --progress        show progress bar
  -s SETTINGS, --settings SETTINGS
                        settings json file
  -o OUTPUT, --output OUTPUT
                        output file (default: stdout)update> markovchain image update -h
usage: markovchain image update [-h] [-P] [-s SETTINGS] [-o OUTPUT]
                                state [input [input ...]]

positional arguments:
  state                 state file
  input                 input file

optional arguments:
  -h, --help            show this help message and exit
  -P, --progress        show progress bar
  -s SETTINGS, --settings SETTINGS
                        settings json file
  -o OUTPUT, --output OUTPUT
                        output file (default: rewrite state file)generate> markovchain image generate -h
usage: markovchain image generate [-h] [-P] [-s SETTINGS]
                                  [-ss STATE_SIZE [STATE_SIZE ...]]
                                  [-S WIDTH HEIGHT] [-l LEVEL] [-c COUNT]
                                  state output

positional arguments:
  state                 state file
  output                output file name format string

optional arguments:
  -h, --help            show this help message and exit
  -P, --progress        show progress bar
  -s SETTINGS, --settings SETTINGS
                        settings json file
  -ss STATE_SIZE [STATE_SIZE ...], --state-size STATE_SIZE [STATE_SIZE ...]
                        generator state sizes
  -S WIDTH HEIGHT, --size WIDTH HEIGHT
                        image size (default: <scanner.resize>)
  -l LEVEL, --level LEVEL
                        image levels (default: <scanner.levels>)
  -c COUNT, --count COUNT
                        generated image count (default: 1)filter> markovchain image filter -h
usage: markovchain image filter [-h] [-P] [-t {json,sqlite}] [-s SETTINGS]
                                [-S STATE] [-ss STATE_SIZE [STATE_SIZE ...]]
                                [-l LEVEL] [-c COUNT]
                                input output

positional arguments:
  input                 input image
  output                output file name format string

optional arguments:
  -h, --help            show this help message and exit
  -P, --progress        show progress bar
  -t {json,sqlite}, --type {json,sqlite}
                        generator type (default: json)
  -s SETTINGS, --settings SETTINGS
                        settings json file
  -S STATE, --state STATE
                        state file
  -ss STATE_SIZE [STATE_SIZE ...], --state-size STATE_SIZE [STATE_SIZE ...]
                        generator state sizes
  -l LEVEL, --level LEVEL
                        filter start level (default: 1)
  -c COUNT, --count COUNT
                        generated image count (default: 1)settings> markovchain image settings -h
usage: markovchain image settings [-h] state

positional arguments:
  state       state file

optional arguments:
  -h, --help  show this help message and exitLicensesmarkovchain