RNN(循环神经网络)学习随笔
欢迎使用Markdown编辑器
# with open('data/script.txt', 'rb') as f:
with open('data/script.txt', 'rb') as f://原代码:f=open(‘data/script.txt’,'rb') f.close()
reader = csv.reader(f, skipinitialspace=True)
reader.next()
# Split full comments into sentences
sentences = itertools.chain(*[nltk.sent_tokenize(x[0].decode('utf-8').lower()) for x in reader])
# Append SENTENCE_START and SENTENCE_END
sentences = ["%s %s %s" % (sentence_start_token, x, sentence_end_token) for x in sentences]
print "Parsed %d sentences." % (len(sentences))