-
Notifications
You must be signed in to change notification settings - Fork 181
/
main.py
31 lines (29 loc) · 1.04 KB
/
main.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
# coding: UTF-8
'''''''''''''''''''''''''''''''''''''''''''''''''''''
file name: main.py
create time: 2017年06月23日 星期五 16时41分54秒
author: Jipeng Huang
e-mail: huangjipengnju@gmail.com
github: https://github.com/hjptriplebee
'''''''''''''''''''''''''''''''''''''''''''''''''''''
from config import *
import data
import model
def defineArgs():
"""define args"""
parser = argparse.ArgumentParser(description = "Chinese_poem_generator.")
parser.add_argument("-m", "--mode", help = "select mode by 'train' or test or head",
choices = ["train", "test", "head"], default = "test")
return parser.parse_args()
if __name__ == "__main__":
args = defineArgs()
trainData = data.POEMS(trainPoems)
MCPangHu = model.MODEL(trainData)
if args.mode == "train":
MCPangHu.train()
else:
if args.mode == "test":
poems = MCPangHu.test()
else:
characters = input("please input chinese character:")
poems = MCPangHu.testHead(characters)