def train(): parser = argparse.ArgumentParser() parser.add_argument("--db", help="Filename for sqlite3 database") parser.add_argument("dir", help="Input directory") # Get arguments or set to defaults args = parser.parse_args() database = args.db or DEFAULT_DATABASE directory = args.dir # Connect to the database session = connect_to_database(database) rhyme_dict = RhymeDictionary(session, 2) print("Training...")
def generate_song(): parser = argparse.ArgumentParser() parser.add_argument("--db", help="Filename for sqlite3 database") parser.add_argument("file", help="Output file") # Get arguments or set to defaults args = parser.parse_args() database = args.db or DEFAULT_DATABASE filename = args.file # Connect to the database session = connect_to_database(database) rhyme_dict = RhymeDictionary(session, 2) print("Generating a song...") with open(filename, "wb") as output_file: output_file.write(rhyme_dict.random_rhyme("lips"))
def get_rhyme_dict(): Session = connect_to_database("test.db") return RhymeDictionary(Session, 0)