-
Notifications
You must be signed in to change notification settings - Fork 0
/
cardboardmarkovgenerator.py
44 lines (32 loc) · 1.13 KB
/
cardboardmarkovgenerator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""CardboardBot Markov chain database generator script"""
import logging
from argparse import ArgumentParser
log = logging.getLogger(__name__)
def main():
import config
from pymarkovchain import MarkovChain
optp = ArgumentParser()
optp.add_argument("-d", "--database", dest="database",
help="Where to store the database")
optp.add_argument("-f", "--file", dest="file",
help="File source to use for generating the database")
opts = optp.parse_args()
# Setup logging.
logformat = '%(levelname)-8s %(name)s %(message)s'
logging.basicConfig(level=logging.INFO,
format=logformat)
if opts.database is None:
try:
opts.database = config.markovbrainfile
except NameError:
log.critical("I require a brainfile to write into!")
exit(1)
if opts.file is None:
log.critical("I require an imput file to learn from!")
exit(1)
mc = MarkovChain(opts.database)
mc.generateDatabase(opts.file)
if __name__ == "__main__":
main()