def test_cli(self): sio = io.StringIO() with contextlib.redirect_stdout(sio): run_module("vecto", "benchmark", "text_classification", path_emb, path_text_classification_dataset, "--model", "cnn", "--path_out", "/tmp/vecto/benchmarks/") sio = io.StringIO() with contextlib.redirect_stdout(sio): run_module("vecto", "benchmark", "text_classification", path_emb, path_text_classification_dataset, "--model", "cnn", "--path_out", "/tmp/vecto/benchmarks/") with self.assertRaises(FileNotFoundError): sio = io.StringIO() with contextlib.redirect_stdout(sio): run_module("vecto", "benchmark", "text_classification", path_emb + "NONEXISTING", path_text_classification_dataset, "--path_out", "/tmp/vecto/benchmarks/") from matplotlib import pyplot as plt visualize.plot_accuracy("/tmp/vecto/benchmarks/text_classification", key_secondary="experiment_setup.dataset") plt.savefig("/tmp/vecto/benchmarks/text_classification.pdf", bbox_inches="tight")
def test_cli(self): sio = io.StringIO() with contextlib.redirect_stdout(sio): run_module("vecto.benchmarks.sequence_labeling", path_emb, path_sequence_labeling_dataset_ner, "--path_out", "/tmp/vecto/benchmarks/") sio = io.StringIO() with contextlib.redirect_stdout(sio): run_module("vecto.benchmarks.sequence_labeling", path_emb, path_sequence_labeling_dataset_ner, "--path_out", "/tmp/vecto/benchmarks/") with self.assertRaises(FileNotFoundError): sio = io.StringIO() with contextlib.redirect_stdout(sio): run_module("vecto.benchmarks.sequence_labeling", path_emb + "NONEXISTING", path_sequence_labeling_dataset_ner, "--path_out", "/tmp/vecto/benchmarks/") from matplotlib import pyplot as plt # here the visualization only for the ner sub task. visualize.plot_accuracy("/tmp/vecto/benchmarks/ner", key_secondary="experiment_setup.dataset") plt.savefig("/tmp/vecto/benchmarks/sequence_labeling.pdf", bbox_inches="tight")
def test_cli(self): sio = io.StringIO() with contextlib.redirect_stdout(sio): run_module("vecto", "benchmark", "language_modeling", path_emb, "--window_size", "5", "--path_out", "/tmp/vecto/benchmarks/") sio = io.StringIO() with contextlib.redirect_stdout(sio): run_module("vecto", "benchmark", "language_modeling", path_emb, "--method", "lr", "--path_out", "/tmp/vecto/benchmarks/tmp") with self.assertRaises(FileNotFoundError): sio = io.StringIO() with contextlib.redirect_stdout(sio): run_module("vecto", "benchmark", "language_modeling", path_emb + "NONEXISTING", "--path_out", "/tmp/vecto/benchmarks/") from matplotlib import pyplot as plt visualize.plot_accuracy("/tmp/vecto/benchmarks/language_modeling", key_secondary="experiment_setup.dataset") plt.savefig("/tmp/vecto/benchmarks/language_modeling.pdf", bbox_inches="tight")
def test_cli(self): sio = io.StringIO() with contextlib.redirect_stdout(sio): run_module("vecto", "benchmark", "analogy", "./tests/data/embeddings/text/plain_with_file_header/", "./tests/data/benchmarks/analogy/", "--path_out", "/tmp/vecto/benchmarks/", "--method", "3CosAdd") sio = io.StringIO() with contextlib.redirect_stdout(sio): run_module("vecto", "benchmark", "analogy", "./tests/data/embeddings/text/plain_with_file_header/", "./tests/data/benchmarks/analogy/", "--path_out", "/tmp/vecto/benchmarks/specific_filename.json", "--method", "LRCos") sio = io.StringIO() with contextlib.redirect_stdout(sio): run_module("vecto", "benchmark", "analogy", "./tests/data/embeddings/text/plain_with_file_header/", "./tests/data/benchmarks/analogy/", "--path_out", "/tmp/vecto/benchmarks/", "--method", "3CosMul") sio = io.StringIO() with self.assertRaises(RuntimeError): with contextlib.redirect_stdout(sio): run_module( "vecto", "benchmark", "analogy", "./tests/data/embeddings/text/plain_with_file_header/", "./tests/data/benchmarks/analogy/", "--method", "NONEXISTING") sio = io.StringIO() with contextlib.redirect_stdout(sio): run_module("vecto", "benchmark", "analogy", "./tests/data/embeddings/text/plain_with_file_header/", "./tests/data/benchmarks/analogy/", "--method", "3CosAvg") # TODO: suppress concatenating timestamp or aggregate multiple runs from matplotlib import pyplot as plt visualize.plot_accuracy("/tmp/vecto/benchmarks/word_analogy") plt.savefig("/tmp/vecto/benchmarks/analogy.pdf", bbox_inches="tight")