读取切好词的文本文件,加载全部词序列
()
| 61 | print "load vectors finish" |
| 62 | |
| 63 | def 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 | |
| 78 | def vector_sqrtlen(vector): |
| 79 | len = 0 |
no test coverage detected