Esempio n. 1
0
def test_from_data_frame():
    not_data_frame = 'test_str'
    not_int = 'test_str'
    params = [[not_data_frame, -1], [DataFrame(), not_int]]
    for df, index in params:
        with pytest.raises(AssertionError):
            Document.from_data_frame(df, index)
    df = read_excel(example_excel_file)
    index = 0
    doc = Document.from_data_frame(df, index)
    assert doc.index == index
    assert sorted(doc.fields.keys()) == sorted(df.columns)
    assert str(doc.fields) == str(df.to_dict('records')[index])
    assert doc.analyzed_sentences == dict()
Esempio n. 2
0
def data_frame_to_document_list(data_frame):
    documents = []
    for i in range(len(data_frame)):
        d = Document.from_data_frame(data_frame=data_frame, index=i)
        documents.append(d)
    return documents