def test_no_other_csvs(self, tmpdir, sentiments): target = tmpdir.mkdir('target') csv_writer = writers.CSVWriter(str(target)) csv_writer.init() csv_writer.write_sentiment(sentiments) csv_writer.close() contents = [f.basename for f in target.listdir()] assert len(contents) == 1 assert 'sentiments.csv' in contents
def csv_concepts_reduced(target, concepts): for response in concepts: for concept in response: del concept['surface'] del concept['relevance_score'] csv_writer = writers.CSVWriter(str(target)) csv_writer.init() csv_writer.write_concepts(concepts) csv_writer.close() return csv_writer
def test_write_sentiment_headers(self, tmpdir, sentiments): target = tmpdir.mkdir('target') csv_writer = writers.CSVWriter(str(target)) csv_writer.init() csv_writer.write_sentiment(sentiments) csv_writer.close() header = target.join('sentiments.csv').readlines()[0].strip() assert 'doc_id' in header assert 'text_order' in header assert 'sentiment_value' in header
def csv_writer(tmpdir, concepts, sentiments, categories, absa): target = tmpdir.mkdir('target') csv_writer = writers.CSVWriter(str(target)) csv_writer.init() csv_writer.write_categories(categories) csv_writer.write_sentiment(sentiments) csv_writer.write_concepts(concepts) csv_writer.write_absa(absa) csv_writer.close() return csv_writer
def test_write_sentiment_values(self, tmpdir, sentiments): target = tmpdir.mkdir('target') csv_writer = writers.CSVWriter(str(target)) csv_writer.init() csv_writer.write_sentiment(sentiments) csv_writer.close() file_lines = target.join('sentiments.csv').readlines() assert len(file_lines) == 3 row1 = file_lines[1].strip().split(',') assert row1[0] == '0' assert row1[1] == '0' assert row1[2].startswith('0.72') row2 = file_lines[2].strip().split(',') assert row2[0] == '1' assert row2[1] == '0' assert row2[2].startswith('0.66')
def csv_concepts(target, concepts): csv_writer = writers.CSVWriter(str(target)) csv_writer.init() csv_writer.write_concepts(concepts) csv_writer.close() return csv_writer
def test_csvwriter_init_with_directory(): csv_writer = writers.CSVWriter('/tmp/test') assert csv_writer.target_dir == '/tmp/test'
def csv_absa(target, absa): csv_writer = writers.CSVWriter(str(target)) csv_writer.init() csv_writer.write_absa(absa) csv_writer.close() return csv_writer
def csv_categories(target, categories): csv_writer = writers.CSVWriter(str(target)) csv_writer.init() csv_writer.write_categories(categories) csv_writer.close() return csv_writer