Skip to content

Commit

Permalink
pass kargs to prepare fn in gensim and graphlab helpers. Closes #6, #7.
Browse files Browse the repository at this point in the history
  • Loading branch information
bmabey committed Jun 16, 2015
1 parent ef4e0f0 commit 497b089
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 5 additions & 3 deletions pyLDAvis/gensim.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _extract_data(topic_model, corpus, dictionary):
return {'topic_term_dists': topic_term_dists, 'doc_topic_dists': doc_topic_dists,
'doc_lengths': doc_lengths, 'vocab': vocab, 'term_frequency': term_freqs}

def prepare(topic_model, corpus, dictionary):
def prepare(topic_model, corpus, dictionary, **kargs):
"""Transforms the Gensim TopicModel and related corpus and dictionary into
the data structures needed for the visualization.
Expand All @@ -46,6 +46,8 @@ def prepare(topic_model, corpus, dictionary):
dictionary: gensim.corpora.Dictionary
The dictionary object used to create the corpus. Needed to extract the
actual terms (not ids).
**kwargs :
additional keyword arguments are passed through to :func:`pyldavis.prepare`.
Returns
-------
Expand All @@ -57,5 +59,5 @@ def prepare(topic_model, corpus, dictionary):
For example usage please see this notebook:
http://nbviewer.ipython.org/github/bmabey/pyLDAvis/blob/master/notebooks/Gensim%20Newsgroup.ipynb
"""

return vis_prepare(**_extract_data(topic_model, corpus, dictionary))
opts = fp.merge(_extract_data(topic_model, corpus, dictionary), kargs)
return vis_prepare(**opts)
7 changes: 5 additions & 2 deletions pyLDAvis/graphlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def _extract_data(topic_model, docs):
return {'topic_term_dists': topic_term_dists, 'doc_topic_dists': doc_topic_dists,
'doc_lengths': doc_lengths, 'vocab': vocab, 'term_frequency': term_freqs}

def prepare(topic_model, docs):
def prepare(topic_model, docs, **kargs):
"""Transforms the GraphLab TopicModel and related corpus data into
the data structures needed for the visualization.
Expand All @@ -38,6 +38,8 @@ def prepare(topic_model, docs):
An already trained GraphLab topic model.
docs : SArray of dicts
The corpus in bag of word form, the same docs used to train the model.
**kwargs :
additional keyword arguments are passed through to :func:`pyldavis.prepare`.
Returns
-------
Expand All @@ -49,4 +51,5 @@ def prepare(topic_model, docs):
For example usage please see this notebook:
http://nbviewer.ipython.org/github/bmabey/pyLDAvis/blob/master/notebooks/GraphLab.ipynb
"""
return vis_prepare(**_extract_data(topic_model, docs))
opts = fp.merge(_extract_data(topic_model, docs), kargs)
return vis_prepare(**opts)

0 comments on commit 497b089

Please sign in to comment.