From 62571d42d55cb0f5222e7dbf5fbde8fabc743a52 Mon Sep 17 00:00:00 2001 From: Blink The Things Date: Tue, 3 Nov 2020 11:05:35 -0500 Subject: [PATCH] Add option for specifying random number generator seed --- markov.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/markov.py b/markov.py index 25b985a..40a9266 100644 --- a/markov.py +++ b/markov.py @@ -22,13 +22,15 @@ import os import spacy parser = argparse.ArgumentParser(description='Generate a novel using Markov chains.') -parser.add_argument('word_file', help='File used for word selection') -parser.add_argument('pos_file', help='File used to build part-of-speech Markov chain') +parser.add_argument('word_file', help='file used for word selection') +parser.add_argument('pos_file', help='file used to build part-of-speech Markov chain') +parser.add_argument('-s', '--seed', type=int, help='seed for random number generator') args = parser.parse_args() nlp = spacy.load('en_core_web_sm') -seed = 12345 +seed = args.seed or 12345 + rng = np.random.default_rng(seed) words_text = ''