Carlos-Francisco Méndez-Cruz

LSA soft clustering

"""Pirated example from Gensim library (a NLP specialized tool):
"""Adapted from Gensim library (a NLP specialized tool):
https://radimrehurek.com/gensim/tut2.html
https://radimrehurek.com/gensim/wiki.html#latent-semantic-analysis
and
Ignacio Arroyo
"""
......@@ -106,13 +106,12 @@ for pertenence, sentence in zip(corpus_lsa, sentences):
#print "%s\t\t%s" % (pertenence, sentence.split("\t")[0])
p=[dict(pertenence)[x] if x in dict(pertenence) else 0.0
for x in xrange(n_topics)]
print "%s %s" % ("".join(sentence.split("\t")[0].split()),
"".join(str(p)[1:].strip("]").split(",")) )
print("{} {}".format("".join(sentence.split("\t")[0].split()), "".join(str(p)[1:].strip("]").split(","))))
else:
if n<n_docs:
pertenence=[dict(pertenence)[x] if x in dict(pertenence) else 0.0
for x in xrange(n_topics)]
print "%s\t\t%s" % (pertenence, sentence)
print("%s\t\t%s" % (pertenence, sentence))
n+=1
else:
break
\ No newline at end of file
......