예제 #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
예제 #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
예제 #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
예제 #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
예제 #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
예제 #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
예제 #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
예제 #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