Skip to content

Commit

Permalink
test weighwords
Browse files Browse the repository at this point in the history
  • Loading branch information
larsmans committed May 6, 2016
1 parent 33ff94b commit 83aded7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion xtas/tasks/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def parsimonious_wordcloud(docs, w=.5, k=10):
Parameters
----------
docs : list
List of documents.
List of documents. Each document should be a list of terms.
w : float
Weight assigned to the document terms when fitting individual models,
Expand Down
19 changes: 19 additions & 0 deletions xtas/tests/test_cluster.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import numbers

from nose.tools import assert_equal, assert_true

from xtas.tasks.cluster import parsimonious_wordcloud


def test_parsimonious_wordcloud():
docs = map(lambda s: s.split(),
[["an apple a day keeps the doctor away"],
["orange is the new black"],
["comparing apples and oranges"]])
lm = parsimonious_wordcloud(docs, k=4)
assert_equal(3, len(lm))
for x in lm:
assert_equal(4, len(x))
term, weight = x
assert_true(isinstance(term, basestring))
assert_true(isinstance(weight, numbers.Real))

0 comments on commit 83aded7

Please sign in to comment.