Skip to content

Instantly share code, notes, and snippets.

@dineybomfim
Last active July 18, 2018 12:11
Show Gist options
  • Save dineybomfim/ce661322504870c73c8cb41428e0fcf2 to your computer and use it in GitHub Desktop.
Save dineybomfim/ce661322504870c73c8cb41428e0fcf2 to your computer and use it in GitHub Desktop.
func buildText(starting: String, length: Int, file: String) -> String {
var text = starting
let strings = loadTextFile(fileName: file)
.replacingOccurrences(of: "\n", with: " ")
.components(separatedBy: " ")
MarkovModel.process(transitions: strings) { matrix in
buildWords(with: &text, length: length, chain: matrix)
}
return text
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment