def add_gen_sentences(num): model = Markov() load_quotes_to_model("QUOTES.JSON", model) model.build_chain() genquotes = [] with open("generated_quotes.json", 'r') as jfile: content = json.load(jfile) genquotes = content["quotes"] for _ in range(num): newQuote = " ".join(model.make_sentence()) maxSimilarity = max(similar(newQuote, i) for i in model.allsentences) if maxSimilarity < 0.85: print(newQuote) print(maxSimilarity) genquotes.append(newQuote) jsonData = {"quotes": genquotes} with open("generated_quotes.json", 'w') as jfile: json.dump(jsonData, jfile)