我正在尝试使用python在我的文本语料库上训练Glove模型,遵循此页面上指定的实现。 Glove model 我在从指定路径读取语料库文件时遇到问题
parser.add_argument('corpus', metavar='corpus_path',
type=partial(codecs.open, encoding='utf-8'))
如何为此参数指定文件路径。 我使用了命令行参数,如下所示
C:\Users\JAYASHREE\Documents\NLP>python Glove_python_bbc.py 'C:/Users/JAYASHREE/Documents/NLP/text-corpus' --vocab-path C:/Users/JAYASHREE/Documents/NLP/vocabulary --cooccur-path C:/Users/JAYASHREE/Documents/NLP/cooccur_matrix -w 10 --min-count 10 --vector-path C:/Users/JAYASHREE/Documents/NLP/word-vector -s 40 --iterations 10 --learning-rate 0.1 --save-often True
我收到错误如下
Traceback (most recent call last):
File "Glove_python_bbc.py", line 380, in <module>
main(parse_args())
File "Glove_python_bbc.py", line 70, in parse_args
return parser.parse_args()
File "C:\Users\JAYASHREE\Anaconda2\lib\argparse.py", line 1701, in parse_args
args, argv = self.parse_known_args(args, namespace)
File "C:\Users\JAYASHREE\Anaconda2\lib\argparse.py", line 1733, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
File "C:\Users\JAYASHREE\Anaconda2\lib\argparse.py", line 1921, in _parse_known_args
positionals_end_index = consume_positionals(start_index)
File "C:\Users\JAYASHREE\Anaconda2\lib\argparse.py", line 1898, in consume_positionals
take_action(action, args)
File "C:\Users\JAYASHREE\Anaconda2\lib\argparse.py", line 1791, in take_action
argument_values = self._get_values(action, argument_strings)
File "C:\Users\JAYASHREE\Anaconda2\lib\argparse.py", line 2231, in _get_values
value = self._get_value(action, arg_string)
File "C:\Users\JAYASHREE\Anaconda2\lib\argparse.py", line 2260, in _get_value
result = type_func(arg_string)
File "C:\Users\JAYASHREE\Anaconda2\lib\codecs.py", line 896, in open
file = __builtin__.open(filename, mode, buffering)
IOError: [Errno 22] invalid mode ('rb') or filename: "'C:/Users/JAYASHREE/Documents/NLP/text-corpus'"
如何将参数传递给语料库路径
由于