Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MarkovChain := Object clone do(
- Message do(
- evalLightMethod := method(scope,
- call message arguments slice(1) foreach(i, arg,
- scope setSlot(arguments at(i) name, call sender doMessage(arg, call sender))
- )
- scope doMessage(self arguments last, scope)
- )
- )
- Map update := method(key,
- atPut(key,
- if(hasKey(key),
- call argAt(2) evalLightMethod(call sender, at(key))
- ,
- call evalArgAt(1)
- )
- )
- self
- )
- m := Map clone
- init := method(
- words := Map clone
- file := File with("./text")
- text := file contents
- file close
- self wordlist := text split
- wordlist foreach (
- index, word,
- addWords(word, (wordlist at(index + 1)
- ,ifTrue(index < worldlist size - 2)
- )
- )
- )
- )
- addWords := method(word,
- words update(word, 0, (count, count + 1))
- )
- getWords :=method(word,
- )
- )
Add Comment
Please, Sign In to add comment