- 前言
- 版本
- 例子
前言
这个例子很简单,但是对我来说够用,日后可以基于这个例子拓展
版本docopt: 0.6.2
python: 3.6
注意要写在import 前面, 否则报错。
"""
Usage:
vocab.py [options] TRAIN_SET_SRC TRAIN_SET_TGT VOCAB_FILE
Options:
-h --help Show this screen.
--size-src INT src vocab size [default: 50000]
--size-tgt INT tgt vocab size [default: 50000]
--freq-cutoff INT frequency cutoff [default: 2]
--vocab-class STR the class name of used Vocab class [default: Vocab]
"""
必选参数:
TRAIN_SET_SRC TRAIN_SET_TGT VOCAB_FILE
可选参数:
-h --help Show this screen.
–size-src INT src vocab size [default: 50000]
–size-tgt INT tgt vocab size [default: 50000]
–freq-cutoff INT frequency cutoff [default: 2]
–vocab-class STR the class name of used Vocab class [default: Vocab]
执行方法:
python ../vocab.py ../samples/train/train.spl.src ../samples/train/train.txt.tgt ../samples/dic/python_dic.json
结果:
{'--freq-cutoff': '2',
'--help': False,
'--size-src': '50000',
'--size-tgt': '50000',
'--vocab-class': 'Vocab',
'TRAIN_SET_SRC': '../samples/train/train.spl.src',
'TRAIN_SET_TGT': '../samples/train/train.txt.tgt',
'VOCAB_FILE': '../samples/dic/python_dic.json'}



