Carlos-Francisco Méndez-Cruz

LSA word embedding examples

...@@ -106,13 +106,13 @@ for pertenence, sentence in zip(corpus_lsa, sentences): ...@@ -106,13 +106,13 @@ for pertenence, sentence in zip(corpus_lsa, sentences):
106 if n_docs <= 0: 106 if n_docs <= 0:
107 #print "%s\t\t%s" % (pertenence, sentence.split("\t")[0]) 107 #print "%s\t\t%s" % (pertenence, sentence.split("\t")[0])
108 p=[dict(pertenence)[x] if x in dict(pertenence) else 0.0 108 p=[dict(pertenence)[x] if x in dict(pertenence) else 0.0
109 - for x in xrange(n_topics)] 109 + for x in range(n_topics)]
110 print("%s %s" % ("".join(sentence.split("\t")[0].split()), 110 print("%s %s" % ("".join(sentence.split("\t")[0].split()),
111 "".join(str(p)[1:].strip("]").split(",")) )) 111 "".join(str(p)[1:].strip("]").split(",")) ))
112 else: 112 else:
113 if n<n_docs: 113 if n<n_docs:
114 pertenence=[dict(pertenence)[x] if x in dict(pertenence) else 0.0 114 pertenence=[dict(pertenence)[x] if x in dict(pertenence) else 0.0
115 - for x in xrange(n_topics)] 115 + for x in range(n_topics)]
116 print("%s\t\t%s" % (pertenence, sentence)) 116 print("%s\t\t%s" % (pertenence, sentence))
117 n+=1 117 n+=1
118 else: 118 else:
......