forked from demidovakatya/markov-chains
-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.py
58 lines (45 loc) · 2.16 KB
/
generate.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import argparse
import logging.config
from src.MCApplication import MCApplication
def main():
args = __parse_args()
logging.config.fileConfig('./logging.conf')
MCApplication(args).run()
def __parse_args():
description = '''
Generate strings using the markov-chains application.\n\nExample:\n\t
generate.py --generator 'mvf' --output_size 10 --src 'b'
'''
parser = argparse.ArgumentParser(description=description)
parser.add_argument('--src',
metavar='SC',
nargs='*',
choices=['b', 'galya.ru', 'woman.ru'],
default=['b', 'galya.ru', 'woman.ru'],
help="(str or multiple str separated by space, from {'b', 'galya.ru', 'woman.ru'}) ---- Sources to use for getting data from the web.")
parser.add_argument('--mode',
action='store',
default='generate',
choices=['generate'])
parser.add_argument('--writer',
action='store',
default='console',
choices=['console', 'txt'],
help="({'console', 'txt'}, default 'console') ---- Preferred output – console or txt file.")
parser.add_argument('--generator',
action='store',
default='mvf',
choices=['mvf', 'mc'],
help="({'mvf', 'mc'}, default 'mvf') ---- Markov chains generator.")
parser.add_argument('--output_size',
action='store',
default=50,
type=int,
help='(int, default 50) ----- Number of lines to be sent to output.')
parser.add_argument('--storage_path',
action='store',
default='./storage',
help="(str, default './storage') ----- Path to folder the output of program will be saved to.")
return vars(parser.parse_args())
if __name__ == '__main__':
main()