Last active
April 25, 2018 08:40
-
-
Save yi-jiayu/f44751443bb0ef491d5ae26e8e363e52 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import sys | |
import markovify | |
def main(files, n): | |
text = '' | |
for f in files: | |
text += f.read() | |
model = markovify.Text(text) | |
for i in range(n): | |
sentence = model.make_sentence(max_overlap_ratio=0.5, tries=20) | |
print(sentence, end='\n\n') | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser( | |
description='Generate new Reddit comments from existing ones.') | |
parser.add_argument('files', metavar='FILE', nargs='*', | |
help='Input file or files containing downloaded comments', | |
type=argparse.FileType('r', encoding='utf-8'), | |
default=sys.stdin) | |
parser.add_argument('-n', dest='n', metavar='COUNT', type=int, help='Number of new comments to generate', | |
default=10) | |
args = parser.parse_args() | |
main(args.files, args.n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment