-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
load_word_topics() returns value #767
Conversation
Rename wordtopics to word_topics. Also should there be a meaningful error like 'run train or load_word_topics before showing topics' in https://github.com/bhargavvader/gensim/blob/6fd1ecbfe41d7ab2adc17d20179d467e986f477a/gensim/models/wrappers/ldamallet.py#L244 |
Will do. Also, this PR doesn't seem to have a travis build happening, any reason? |
oh renaming to |
@bhargavvader Well spotted about Travis - other PRs are working ok. Let's see what happens on your next commit. |
@dsquareindia , exactly what else would break? Not if we change all the |
@bhargavvader the |
@dsquareindia , made the changes in
|
yeah @bhargavvader I'll make both the changes in my pr once this gets merged. Thanks! |
@tmylk , @piskvorky , can you have a look? |
@@ -242,7 +242,9 @@ def show_topics(self, num_topics=10, num_words=10, log=False, formatted=True): | |||
return shown | |||
|
|||
def show_topic(self, topicid, topn=10): | |||
topic = self.wordtopics[topicid] | |||
if self.word_topics is None: | |||
logger.info("Run train or load_word_topics before showing topics.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warn instead of info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, did.
Thanks for the PR. It's a useful fix! |
-1 on renaming |
logger.info("loaded assigned topics for %i tokens", wordtopics.sum()) | ||
self.wordtopics = wordtopics | ||
word_topics[int(topic), tokenid] += 1.0 | ||
logger.info("loaded assigned topics for %i tokens", word_topics.sum()) | ||
self.print_topics(15) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This print makes no sense without the self.wordtopics
assignment.
@tmylk did you review this before merging??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right - the print was there in the code earlier and I removed the self.wordtopics
assignment so now it doesn't make sense.
@piskvorky , how exactly would one make an alias? I'll make another PR for that and for the unnecessary print statement. Is there anything else you think should change? |
I mean, we use it in our own code, in commercial projects :) I think it's safe to assume some other people depend on it too, in the same way. Unless it's unavoidable, we try to be backward-compatible with our changes. Alias = two variables referring to the same object, i.e. |
Ok, makes sense. As for making an alias in this case, would you mean adding a line such as |
Yes, assign Option two: just continue to call the var |
@tmylk, @piskvorky , with reference to #764 .
load_word_topics()
now returnsword topics
which is assigned bytrain
toself.wordtopics
.Before, there were two variables;
word_topics
and awordtopics
, and only thewordtopics
variable was being used elsewhere; so I removedword_topics
.Is that ok?