def test_convert_bow_to_vw(self): bow = BOW().load(source=paths.BOW) vocabulary = [ "i.", "i.*", "i.Activity", "i.AdapterView", "i.ArrayAdapter", "i.Arrays" ] with tempfile.NamedTemporaryFile(prefix="sourced.ml-vw-") as fout: logging.getLogger().level = logging.ERROR try: bow.convert_bow_to_vw(fout.name) finally: logging.getLogger().level = logging.INFO fout.seek(0) contents = fout.read().decode() hits = 0 for word in vocabulary: if " %s:" % word in contents: hits += 1 self.assertEqual(hits, 4)
def bow2vw_entry(args: argparse.Namespace): bow = BOW().load(source=args.bow) bow.convert_bow_to_vw(args.output)