In [1]:
import spacy
In [2]:
nlp = spacy.load('en') ## Load spacy
In [3]:
## Tokens
doc = nlp(u'Hello Rishu, this is a test nlp document.')
for tokens in doc:
print(tokens)
In [4]:
## Parts of speech, tags
for tokens in doc:
print(tokens, " | ", tokens.pos, " | ", tokens.pos_, " | ")
In [5]:
### itentifying sentences:
doc2 = nlp(u"This is a sentence. This is the first sentense. This is the third sentence")
for sentenses in doc2.sents:
print(sentenses)
In [6]:
doc2[5]
Out[6]:
In [7]:
type(doc2[5])
Out[7]:
In [8]:
doc2[5].is_sent_start
Out[8]:
In [9]:
doc2[8].is_sent_start ## no output display. Returned None
In [ ]:
In [10]:
doc3 = nlp(u"A 5km ride to London zone 1 cost £20.00")
In [11]:
for tokens in doc3:
print(tokens.text)
In [13]:
doc4 = nlp(u"A 5km ride to London zone 1 cost £20.00")
import dispacy
In [ ]: