<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Intro Spacy
Step2:  Spacy Documentation
Spacy is an NLP/Computational Linguistics package built from the ground up. It's written in Cython so it's fast!!
Let's check it out. Here's some text from Alice in Wonderland free on Gutenberg.
Step3:  Download and load the model. SpaCy has an excellent English NLP processor. It has the following features which we shall explore
Step4:  Looks like the same text? Let's dig a little deeper
Tokenization
Sentences
Step5:  Words and Punctuation - Along with POS tagging
Step6:  Entities - Explanation of Entity Types
Step7:  Noun Chunks
Step8:  The Semi Holy Grail - Syntactic Depensy Parsing See Demo for clarity
Step9:  What is 'nsubj'? 'acomp'? See The Universal Dependencies
Word Vectorization - Word2Vec
<ASSISTANT_TASK:>
Python Code:
!pip install spacy nltk
Explanation: Intro Spacy
End of explanation
text = 'Please would you tell me,' said Alice, a little timidly, for she was not quite sure whether it was good manners for her to speak first, 'why your cat grins like that?'
'It's a Cheshire cat,' said the Duchess, 'and that's why. Pig!'
She said the last word with such sudden violence that Alice quite jumped; but she saw in another moment that it was addressed to the baby, and not to her, so she took courage, and went on again:—
'I didn't know that Cheshire cats always grinned; in fact, I didn't know that cats could grin.'
'They all can,' said the Duchess; 'and most of 'em do.'
'I don't know of any that do,' Alice said very politely, feeling quite pleased to have got into a conversation.
'You don't know much,' said the Duchess; 'and that's a fact.'
Explanation: Spacy Documentation
Spacy is an NLP/Computational Linguistics package built from the ground up. It's written in Cython so it's fast!!
Let's check it out. Here's some text from Alice in Wonderland free on Gutenberg.
End of explanation
import spacy
import spacy.en.download
# spacy.en.download.main()
processor = spacy.en.English()
processed_text = processor(text)
processed_text
Explanation: Download and load the model. SpaCy has an excellent English NLP processor. It has the following features which we shall explore:
- Entity recognition
- Dependency Parsing
- Part of Speech tagging
- Word Vectorization
- Tokenization
- Lemmatization
- Noun Chunks
Download the Model, it may take a while
End of explanation
n = 0
for sentence in processed_text.sents:
    print(n, sentence)
    n+=1
Explanation: Looks like the same text? Let's dig a little deeper
Tokenization
Sentences
End of explanation
n = 0
for sentence in processed_text.sents:
    for token in sentence:
        print(n, token, token.pos_, token.lemma_)
        n+=1
Explanation: Words and Punctuation - Along with POS tagging
End of explanation
for entity in processed_text.ents:
    print(entity, entity.label_)
Explanation: Entities - Explanation of Entity Types
End of explanation
for noun_chunk in processed_text.noun_chunks:
    print(noun_chunk)
Explanation: Noun Chunks
End of explanation
def pr_tree(word, level):
    if word.is_punct:
        return
    for child in word.lefts:
        pr_tree(child, level+1)
    print('\t'* level + word.text + ' - ' + word.dep_)
    for child in word.rights:
        pr_tree(child, level+1)
for sentence in processed_text.sents:
    pr_tree(sentence.root, 0)
    print('-------------------------------------------')
Explanation: The Semi Holy Grail - Syntactic Depensy Parsing See Demo for clarity
End of explanation
proc_fruits = processor('''I think green apples are delicious. 
                            While pears have a strange texture to them. 
                            The bowls they sit in are ugly.''')
apples, pears, bowls = proc_fruits.sents
fruit = processed_text.vocab['fruit']
print(apples.similarity(fruit))
print(pears.similarity(fruit))
print(bowls.similarity(fruit))
Explanation: What is 'nsubj'? 'acomp'? See The Universal Dependencies
Word Vectorization - Word2Vec
End of explanation
<END_TASK>