forked from t1101675/word2vec
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cbow.py
More file actions
31 lines (25 loc) · 760 Bytes
/
test_cbow.py
File metadata and controls
31 lines (25 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import CBOW
import build_tree
import os
f = open("1M_test.in", 'r')
sentence = f.read()
# print sentence
model = CBOW.CBOW(sentence)
# model.buildWordList()
# print model.trainWordList
# for word in model.wordVecDict:
# print word + ": ", model.wordVecDict[word]
# for word in model.wordVecDict:
# print word + ": ", model.wordPosiDict[word]
# model.buildTree()
# for word in model.tree.wordCodeDict:
# code = model.tree.wordCodeDict[word]
# node = model.tree.root
# for i in range(len(code)):
# if node is None:
# raise RuntimeError("code length not right")
# if code[i] == "0":
# node = node.left
# else:
# node = node.right
# print word, ", ", code, ", ", node.value