title: gematria function - processing a text according to numerical values
body: <p>I'm trying to process a text, i.e. the Bible, extracting the numerical values of the letters of its words, according to a dictionary:</p>
  
  <pre><code>def gematria(book):
  
      dict = {
                'a':1, 'b':2, 'c':3, 'd':4, 'e':5, 
                'f':80, 'g':3, 'h':8,'i':10, 'j':10,
                'k':20, 'l':30, 'm':40, 'n':50, 'o':70,
                'p':80, 'q':100,'r':200, 's':300,
                't':400, 'u':6, 'v':6, 'w':800, 'x':60, 
                'y':10, 'z':7
             }
  </code></pre>
  
  <p>Using the Nltk module, I've come down to:</p>
  
  <pre><code>raw = nltk.corpus.gutenberg.raw(book)
  tokens = nltk.word_tokenize(raw)
  words_and_numbers = [w.lower() for w in tokens]
  words = [w for w in words_and_numbers if re.search('[^0-9:0-9]', w)]
  vocab = sorted(set(words))
  nested = [list(w) for w in vocab]
  </code></pre>
  
  <p>I end up with lists with strings for each word's letters, 
  i.e. <code>[['h', 'o', 'l', 'y'],['b', 'i', 'b', 'l', 'e']...]</code></p>
  
  <p>In order to process individual words and have their numerical values, the following list comprehensions, followed by the function <code>sum()</code>, work:</p>
  
  <pre><code>word_value_1 = [dict[letter] for letter in nested[0]]
  sum(word_value_1)
  
  word_value_2 = [dict[letter] for letter in nested[1]]
  sum(word_value_2)
  
  (...)
  </code></pre>
  
  <p>QUESTION: How can I write a single list comprehension, or a loop, that returns me the numerical values for all of the words in a book, in a big list?</p>