简体   繁体   English

如何将包含空格的文件路径传递给Gensim LDA Mallet包装器?

[英]How do I pass a file path containing spaces to the Gensim LDA Mallet wrapper?

I am attempting to use Gensim's Mallet wrapper. 我正在尝试使用Gensim的槌状包装纸。 When I run the following code: 当我运行以下代码时:

import os
import gensim

os.environ.update({
        'MALLET_HOME':
        r":C\Users\me\OneDrive - My Company\Documents\Projects\Current\mallet-2.0.8"
    })
lda_mallet = gensim.models.wrappers.LdaMallet(
        r"C:\Users\me\OneDrive - My Company\Documents\Projects\Current\mallet-2.0.8\bin\mallet",
        corpus=corpus,
        num_topics=10,
        id2word=id_dict)

I am thrown the following errors: 我被抛出以下错误:

'C:\Users\me\OneDrive' is not recognized as an internal or external command,
operable program or batch file.

subprocess.CalledProcessError: Command 'C:\Users\me\OneDrive - My Company\Documents\Projects\Current\mallet-2.0.8\bin\mallet import-file --preserve-case --keep-sequence --remove-stopwords --token-regex "\S+" --input C:\Users\me\AppData\Local\Temp\17fe21_corpus.txt --output C:\Users\me\AppData\Local\Temp\17fe21_corpus.mallet' returned non-zero exit status 1.

After exhaustive online searches, I have found many proposed solutions that unfortunately do not resolve my issue. 经过详尽的在线搜索之后,我发现许多建议的解决方案都不幸无法解决我的问题。

Since the first error message does not print the entire path, I believe the spaces are the cause of the issue. 由于第一条错误消息无法打印出完整路径,因此我相信空格是导致此问题的原因。

Unfortunately, my company requires that I use this directory and I cannot change the name. 不幸的是,我的公司要求我使用此目录,并且不能更改名称。 Is there a way to "escape" the spaces in order to run my code? 有没有一种方法可以“转义”空格以运行我的代码?

好吧,这很容易, LdaMallet类是一个写得不好的软件,向其创建者报告此错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM