Guest User

Untitled

a guest
Feb 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. MarkovChain := Object clone do(
  2.  
  3. Message do(
  4. evalLightMethod := method(scope,
  5. call message arguments slice(1) foreach(i, arg,
  6. scope setSlot(arguments at(i) name, call sender doMessage(arg, call sender))
  7. )
  8. scope doMessage(self arguments last, scope)
  9. )
  10. )
  11.  
  12. Map update := method(key,
  13. atPut(key,
  14. if(hasKey(key),
  15. call argAt(2) evalLightMethod(call sender, at(key))
  16. ,
  17. call evalArgAt(1)
  18. )
  19. )
  20. self
  21. )
  22.  
  23. m := Map clone
  24.  
  25. init := method(
  26.  
  27. words := Map clone
  28.  
  29. file := File with("./text")
  30. text := file contents
  31. file close
  32.  
  33. self wordlist := text split
  34.  
  35. wordlist foreach (
  36. index, word,
  37. addWords(word, (wordlist at(index + 1)
  38. ,ifTrue(index < worldlist size - 2)
  39. )
  40. )
  41. )
  42. )
  43.  
  44. addWords := method(word,
  45. words update(word, 0, (count, count + 1))
  46. )
  47.  
  48. getWords :=method(word,
  49. )
  50. )
Add Comment
Please, Sign In to add comment