在python中进行情感分析时遇到问题

时间:2020-06-28 09:30:22

标签: python-2.7 markov

我在执行Morkov模型时遇到问题

import markovify
import sys

# Read text from file
if len(sys.argv) != 2:
    sys.exit("Usage: python generator.py sample.txt")
with open(sys.argv[1]) as f:
    text = f.read()

# Train model
text_model = markovify.Text(text)

# Generate sentences
print()
for i in range(5):
    print(text_model.make_sentence())
    print()

我收到以下错误报告

 An exception has occurred, use %tb to see the full traceback.

SystemExit: Usage: python generator.py sample.txt

请解决我的问题

1 个答案:

答案 0 :(得分:0)

使用此命令在命令行中执行代码。

python generator.py sample.txt

代码中的generator.py python文件和sample.txt文件为数据集文件