title: How to work with SpaCy parser?
body: <p>I have an example for working with NLP in spacy code:</p>
  
  <pre><code>from numpy import dot
  from numpy.linalg import norm
  
  # you can access known words from the parser's vocabulary
  nasa = parser.vocab['NASA']
  
  # cosine similarity
  cosine = lambda v1, v2: dot(v1, v2) / (norm(v1) * norm(v2))
  
  # gather all known words, take only the lowercased versions
  allWords = list({w for w in parser.vocab if w.has_repvec and w.orth_.islower() and w.lower_ != "nasa"})
  
  # sort by similarity to NASA
  allWords.sort(key=lambda w: cosine(w.repvec, nasa.repvec))
  allWords.reverse()
  print("Top 10 most similar words to NASA:")
  for word in allWords[:10]:   
      print(word.orth_)
  
  # Let's see if it can figure out this analogy
  # Man is to King as Woman is to ??
  king = parser.vocab['king']
  man = parser.vocab['man']
  woman = parser.vocab['woman']
  
  result = king.repvec - man.repvec + woman.repvec
  
  # gather all known words, take only the lowercased versions
  allWords = list({w for w in parser.vocab if w.has_repvec and w.orth_.islower() and w.lower_ != "king" and w.lower_ != "man" and w.lower_ != "woman"})
  # sort by similarity to the result
  allWords.sort(key=lambda w: cosine(w.repvec, result))
  allWords.reverse()
  print("\n------------------\nTop 3 closest results for king - man + woman:")
  for word in allWords[:3]:   
      print(word.orth_)
  </code></pre>
  
  <p>Before I installed all dictionaries for spacy:</p>
  
  <pre><code>$ sudo python -m spacy.en.download all
  $ python -m spacy.en.download parser
  $ python -m spacy.en.download glove
  </code></pre>
  
  <p>but, as results, I have a mistake:</p>
  
  <pre><code>Traceback (most recent call last):
    File "/home/vv/PythProj/sp_ex_1.py", line 5, in &lt;module&gt;
      nasa = parser.vocab['NASA']
  NameError: name 'parser' is not defined
  </code></pre>
  
  <p>Please, Where is my mistake? Thank you</p>