"GreatEspectations.txt", "TaleOfTwoCities.txt" ] for i in range(len(bookArray)): bookArray[i] = "/home/team2/Project/" + bookArray[i] #enter number of sentences here numSentences = 12 #enter word you would like to start with startWord = 'a' markovModel = DFMaker(bookArray) edgeDF = markovModel.createEdgeDF(sc) verticiesDF = markovModel.getVerticiesDF(sc) graphFrame = GraphFrame(verticiesDF, edgeDF) sentences = "" if verticiesDF[verticiesDF["id"] == startWord].collect() == []: print("The word you entered does not appear in any of the texts!") else: markovChain = MarkovChain(graphFrame, startWord) while numSentences > 0: currentState = markovChain.getState() if currentState in string.punctuation: numSentences -= 1 sentences += markovChain.getState() + " " markovChain.nextState() print(sentences) print(markovModel.sortedLikeliness("the"))