[英]How can I make my deeplearning chatbot use the correct path to my dataset?
I am trying to get the code from a deeplearning chatbot to work.我正在尝试从深度学习聊天机器人中获取代码以使其工作。 This chatbot uses pytorch and the dataset from Cornell movie corpus.
这个聊天机器人使用 pytorch 和来自康奈尔电影语料库的数据集。 But the code can't seem to find the path to the dataset, and I don't know how to code it in. This is the source for the deeplearning chatbot code [https://colab.research.google.com/github/pytorch/tutorials/blob/gh-pages/_downloads/chatbot_tutorial.ipynb][1]
但是代码好像找不到数据集的路径,也不知道怎么写进去。这是deeplearning chatbot代码的来源[https://colab.research.google.com/github /pytorch/tutorials/blob/gh-pages/_downloads/chatbot_tutorial.ipynb][1]
This is as far as I've gotten with it.这就是我所掌握的。
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import torch
from torch.jit import script, trace
import torch.nn as nn
from torch import optim
import torch.nn.functional as F
import csv
import random
import re
import os
import unicodedata
import codecs
from io import open
import itertools
import math
USE_CUDA = torch.cuda.is_available()
device = torch.device("cuda" if USE_CUDA else "cpu")
corpus_name = "cornell movie-dialogs corpus"
corpus = os.path.join("data", corpus_name)
def printLines(file, n=10):
with open(file, 'rb') as datafile:
lines = datafile.readlines()
for line in lines[:n]:
print(line)
printLines(os.path.join(corpus, "movie_lines.txt"))
And this is my error log这是我的错误日志
D:\Documents\Python\python pycharm files\pythonProject4\3.9 Chatbot.py:26: SyntaxWarning: 'str' object is not callable; perhaps you missed a comma?
corpus = "D:\Documents\Python\intents\cornell_movie_dialogs_corpus.zip\cornell movie-dialogs corpus\\"("data", corpus_name)
Traceback (most recent call last):
File "D:\Documents\Python\python pycharm files\pythonProject4\3.9 Chatbot.py", line 26, in <module>
corpus = "D:\Documents\Python\intents\cornell_movie_dialogs_corpus.zip\cornell movie-dialogs corpus\\"("data", corpus_name)
TypeError: 'str' object is not callable
I hope there is a solution that doesn't alter the source code too much, but any tips or help are welcome.我希望有一个不会过多改变源代码的解决方案,但欢迎任何提示或帮助。
I solved my problem by removing anything but the cornell movie-dialogs corpus map.我通过删除除康奈尔电影对话语料库地图之外的任何内容来解决我的问题。 And then replacing the word "data" in line 26 with the directory of that map.
然后用该地图的目录替换第 26 行中的“数据”一词。 This fixed it for me
这为我修好了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.