Add the last one
This commit is contained in:
parent
5769eca2f2
commit
f40da609ad
4 changed files with 170 additions and 0 deletions
31
markovread.lua
Normal file
31
markovread.lua
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
local markov_name = "bigmarkov.txt"
|
||||
|
||||
dofile(markov_name)
|
||||
|
||||
--print(Markov)
|
||||
|
||||
local words={}
|
||||
local n=0
|
||||
|
||||
for k,v in pairs(Markov) do
|
||||
n=n+1
|
||||
words[n]=k
|
||||
end
|
||||
|
||||
local sentence = {}
|
||||
|
||||
sentence[1] = words[math.random(#words)]
|
||||
|
||||
for x=2,10,1 do
|
||||
local lastword = sentence[x-1]
|
||||
if not (Markov[lastword] == nil) then
|
||||
sentence[x] = Markov[lastword][math.random(#Markov[lastword])]
|
||||
end
|
||||
end
|
||||
|
||||
local output = ""
|
||||
for k,v in pairs(sentence) do
|
||||
output = output .. v .. " "
|
||||
end
|
||||
|
||||
print(output)
|
||||
Loading…
Add table
Add a link
Reference in a new issue