MCPcopy Create free account
hub / github.com/chinawithfrank/ChatBotCourse / init_seq

Function init_seq

chatbotv2/my_seq2seq.py:63–76  ·  view source on GitHub ↗

读取切好词的文本文件,加载全部词序列

()

Source from the content-addressed store, hash-verified

61 print "load vectors finish"
62
63def init_seq():
64 """读取切好词的文本文件,加载全部词序列
65 """
66 file_object = open('zhenhuanzhuan.segment', 'r')
67 vocab_dict = {}
68 while True:
69 line = file_object.readline()
70 if line:
71 for word in line.decode('utf-8').split(' '):
72 if word_vector_dict.has_key(word):
73 seq.append(word_vector_dict[word])
74 else:
75 break
76 file_object.close()
77
78def vector_sqrtlen(vector):
79 len = 0

Callers 1

generate_trainig_dataMethod · 0.70

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected