Showing
1 changed file
with
4 additions
and
5 deletions
1 | -"""Pirated example from Gensim library (a NLP specialized tool): | 1 | +"""Adapted from Gensim library (a NLP specialized tool): |
2 | https://radimrehurek.com/gensim/tut2.html | 2 | https://radimrehurek.com/gensim/tut2.html |
3 | https://radimrehurek.com/gensim/wiki.html#latent-semantic-analysis | 3 | https://radimrehurek.com/gensim/wiki.html#latent-semantic-analysis |
4 | - | 4 | +and |
5 | Ignacio Arroyo | 5 | Ignacio Arroyo |
6 | """ | 6 | """ |
7 | 7 | ||
... | @@ -106,13 +106,12 @@ for pertenence, sentence in zip(corpus_lsa, sentences): | ... | @@ -106,13 +106,12 @@ for pertenence, sentence in zip(corpus_lsa, sentences): |
106 | #print "%s\t\t%s" % (pertenence, sentence.split("\t")[0]) | 106 | #print "%s\t\t%s" % (pertenence, sentence.split("\t")[0]) |
107 | p=[dict(pertenence)[x] if x in dict(pertenence) else 0.0 | 107 | p=[dict(pertenence)[x] if x in dict(pertenence) else 0.0 |
108 | for x in xrange(n_topics)] | 108 | for x in xrange(n_topics)] |
109 | - print "%s %s" % ("".join(sentence.split("\t")[0].split()), | 109 | + print("{} {}".format("".join(sentence.split("\t")[0].split()), "".join(str(p)[1:].strip("]").split(",")))) |
110 | - "".join(str(p)[1:].strip("]").split(",")) ) | ||
111 | else: | 110 | else: |
112 | if n<n_docs: | 111 | if n<n_docs: |
113 | pertenence=[dict(pertenence)[x] if x in dict(pertenence) else 0.0 | 112 | pertenence=[dict(pertenence)[x] if x in dict(pertenence) else 0.0 |
114 | for x in xrange(n_topics)] | 113 | for x in xrange(n_topics)] |
115 | - print "%s\t\t%s" % (pertenence, sentence) | 114 | + print("%s\t\t%s" % (pertenence, sentence)) |
116 | n+=1 | 115 | n+=1 |
117 | else: | 116 | else: |
118 | break | 117 | break |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment