Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: name 'exit' is not defined #37

Closed
zysNLP opened this issue Nov 27, 2018 · 13 comments
Closed

NameError: name 'exit' is not defined #37

zysNLP opened this issue Nov 27, 2018 · 13 comments

Comments

@zysNLP
Copy link

zysNLP commented Nov 27, 2018

在运行demo_chatbot.py时报错,显示Chatbot-master/Chatbot/RuleMatcher文件夹下的rulebase.py第216行exit()出现错误:NameError: name 'exit' is not defined
在运行demo.py时也会报同样的错,因为调用的同样时这个rulebase.py
我的环境是python3.6.3,请问怎么回事?

@zake7749
Copy link
Owner

如果您是進到 216 行才出錯的話,
那應該是沒有正確配置好詞向量的路徑所致。

@zysNLP
Copy link
Author

zysNLP commented Nov 27, 2018

那请问如何配置词向量的路径?

@zysNLP
Copy link
Author

zysNLP commented Nov 27, 2018

我在“问答测试用资料集”下的“这里”下载时,打开的网页错误,可以给我单独发一份数据么,648634000@qq.com

@zake7749
Copy link
Owner

將詞向量路徑設為參數就可以完成配置:

Chatbot(w2v_model_path='your_model')

之前的測試數據似乎遺失了,我重新上傳了一份
如果還是不能下載,我明天再發到您的 qq 郵箱。

@zysNLP
Copy link
Author

zysNLP commented Nov 29, 2018

还是打不开这个链接,还得麻烦您给我发邮箱里吧,多谢!

@zysNLP
Copy link
Author

zysNLP commented Nov 29, 2018

您好,我始终不知道下载了您打github这些代码以后怎么操作,我python demo.py;python demo_chatbot.py;python demo_qa.py都不能正常运行,请问下载以后具体怎么操作才能正确得到一个聊天机器人的对话,可以跟我讲一下具体步骤么,感谢!!!

@zake7749
Copy link
Owner

您能告訴我不能正常運行回報的錯誤是什麼嗎?

@zysNLP
Copy link
Author

zysNLP commented Nov 29, 2018

运行demo_chatbot.py还是报错NameError: name 'exit' is not defined

@zake7749
Copy link
Owner

請給我整個 traceback,這樣我才知道程式的調用順序跟出錯位置。

關於這個錯誤,您只要於出錯檔案的一開始輸入

from sys import exit

即可避免,但這並不能解決問題。
因為只有發生錯誤時我才會調用這個指令
我想知道的是您遇到的錯誤是這六個情形中的哪一種。

@zysNLP
Copy link
Author

zysNLP commented Nov 29, 2018

我把那个开关设置成True了,运行出现:
zys@zys:~/文档/chatbot/Chatbot-master$ python demo_chatbot.py
/home/zys/anaconda3/lib/python3.6/site-packages/fuzzywuzzy/fuzz.py:11: UserWarning: Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning
warnings.warn('Using slow pure-python SequenceMatcher. Install python-Levenshtein to remove this warning')
[Console] Building a console...
Building prefix dict from the default dictionary ...
Loading model from cache /tmp/jieba.cache
Loading model cost 0.488 seconds.
Prefix dict has been built succesfully.
Building prefix dict from /home/zys/文档/chatbot/Chatbot-master/Chatbot/jieba_dict/dict.txt.big ...
Loading model from cache /tmp/jieba.u571d1d67ba51d2ba0ef5900da5ed0c61.cache
Loading model cost 0.838 seconds.
Prefix dict has been built succesfully.
[Console] Loading the word embedding model...
[Gensim] FileNotFoundError [Errno 2] No such file or directory: 'model/ch-corpus-3sg.bin'

@zake7749
Copy link
Owner

這個錯誤是因為 Chatbot 沒有抓到詞向量所導致的,
根據您設的參數,需於資料夾 model 中放置 ch-corpus-3sg.bin

@zysNLP
Copy link
Author

zysNLP commented Nov 30, 2018

你好,这个文件从哪里来呢

@zake7749
Copy link
Owner

請自行訓練,可參考word2vec-tutorial

@zake7749 zake7749 closed this as completed Apr 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants