 
   constructor: (corpora, dictionary, lookback = 2) ->
     @content = ""
+    @lookback = lookback
+    @chain = new Chain(@lookback)
     @loadCorpora corpora
-    $.get dictionary, {}, (data) => @dictionary = data if dictionary
-    @lookback = lookback
+    #$.get dictionary, {}, (data) => @dictionary = data if dictionary
+    @dictionary = ['alpha', 'bravo', 'charlie', 'delta']
     @words = {}
-    @chain = new Chain(@lookback)
     @makeWords()
 
   loadCorpora: (corpora) =>
-    $.get('/language/corpus/load', {corpus: corpus}, (data) => @content += data)  for corpus in corpora
+    $.get('/language/corpus/load', {corpus: corpus}, (data) => @chain.add data)  for corpus in corpora
 
   makeWords: =>
-    (english, madeUp) ->  @words[english] = madeUp for english, madeUp in [].push [word, @makeWord()] for word of @dictionary
+    (english, madeUp) =>  @words[english] = madeUp for english, madeUp in ([].push [word, @makeWord()] for word of @dictionary)
     @words
 
   makeWord: =>
     word = ""
     key = []
-    key.push new StartWord for i in [lookback..0]
-    while true
-      char = @chain[key].choice()
+    key.push new StartWord for i in [@lookback..0]
+    while @chain.store[key]
+      char = @chain.store[key].choice()
       if typeof char == 'EndWord'
         break
       word += char

  add: (string) =>
    @key = []
    @key.push new StartWord() for i in [@lookback..0]
    console.log @key
    @addChar char for char in string
    @store[@key] || = new CharList()
    @store[@key].add(new EndWord)

  addChar: (char) =>
    #console.log char
    @store[@key] ||= new CharList
    @store[@key].add char
    #console.log @store[@key]
    @key.push(char)
    @key.shift()
    #console.log @key

# Markov chain representation using a Markov Chain implementation to
# make fantasy words from list of corpora.


  constructor: ->
    @chars = {}
    @total = 0

  # add a single character
  add: (char) =>
    @chars[char] ||= 0
    @chars[char] += 1
    @total += 1

  chars:
    @chars

  # sum up all the character values
  total: =>
    @total

  # select a character based on a random value compared with the
  # character probability factorposition
  #
  # for example, assuming a structure of
  # a: 22
