无法使用gensim m在Databricks中执行主题建模

2024-06-11 15:04:46 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用Mallet的Gesim包装器在Databricks上执行主题建模。你知道吗

我已经在本地系统上运行了相同的代码。你知道吗

以下是一些已经在我的本地系统上运行的示例代码:

import os

os.environ['MALLET_HOME'] = 'C:/Users/Soumadiptya.c/Desktop/mallet-2.0.8'

mallet_path = 'C:/Users/Soumadiptya.c/Desktop/mallet-2.0.8/bin/mallet'

ldamallet_model = gensim.models.wrappers.ldamallet.LdaMallet(mallet_path, corpus=corpus, num_topics=20, id2word=id2word, random_seed = 123)

下面是我试图在Databricks实例上执行的操作:

os.environ['MALLET_HOME'] = '/dbfs/FileStore/tables/mallet-2.0.8'

mallet_path_new = '/dbfs/FileStore/tables/mallet-2.0.8/bin/mallet'

new_model = gensim.models.wrappers.ldamallet.LdaMallet(mallet_path_new, corpus=corpus, num_topics=20, id2word=id2word)

但存在以下错误:

CalledProcessError: Command '/dbfs/FileStore/tables/mallet-2.0.8/bin/mallet import-file --preserve-case --keep-sequence --remove-stopwords --token-regex "\S+" --input /tmp/e091ce_corpus.txt --output /tmp/e091ce_corpus.mallet' returned non-zero exit status 126

请注意,我已经导入必要的mallet文件到提到的目录和路径本身存在。我假设问题是在databricks中设置Env变量,但无法解决。任何帮助都将不胜感激。你知道吗


Tags: path代码importnewtablesbinos系统