Example #1
0
def test_docs_from_document_term_matrix():
    dtm = [[2, 1], [3, 2]]
    docs = [[0, 0, 1], [0, 0, 0, 1, 1]]
    assert utils.docs_from_document_term_matrix(dtm) == docs
Example #2
0
def test_docs_from_dtm_with_gaps():
    dtm = [[2, 0, 1], [1, 1, 1]]
    docs = [[0, 0, 2], [0, 1, 2]]
    assert utils.docs_from_document_term_matrix(dtm) == docs
Example #3
0
def test_docs_from_numpy_dtp():
    dtm = np.array([[2, 1], [3, 2]])
    docs = [[0, 0, 1], [0, 0, 0, 1, 1]]
    assert utils.docs_from_document_term_matrix(dtm) == docs
Example #4
0
def test_docs_from_document_term_matrix_with_vocab():
    dtm = [[2, 1], [3, 2]]
    docs = [['cat', 'cat', 2], ['cat', 'cat', 'cat', 2, 2]]
    gen_docs = utils.docs_from_document_term_matrix(dtm, vocab=['cat', 2])
    assert gen_docs == docs
Example #5
0
def test_docs_from_document_term_matrix():
    dtm = [[2, 1], [3, 2]]
    docs = [[0, 0, 1], [0, 0, 0, 1, 1]]
    assert utils.docs_from_document_term_matrix(dtm) == docs
Example #6
0
def test_docs_from_numpy_dtp():
    dtm = np.array([[2, 1], [3, 2]])
    docs = [[0, 0, 1], [0, 0, 0, 1, 1]]
    assert utils.docs_from_document_term_matrix(dtm) == docs
Example #7
0
def test_docs_from_dtm_with_gaps():
    dtm = [[2, 0, 1], [1, 1, 1]]
    docs = [[0, 0, 2], [0, 1, 2]]
    assert utils.docs_from_document_term_matrix(dtm) == docs
Example #8
0
def test_docs_from_document_term_matrix_with_vocab():
    dtm = [[2, 1], [3, 2]]
    docs = [['cat', 'cat', 2], ['cat', 'cat', 'cat', 2, 2]]
    gen_docs = utils.docs_from_document_term_matrix(dtm, vocab=['cat', 2])
    assert gen_docs == docs