Created
July 16, 2021 16:08
-
-
Save James-McNeill/7466f004be7b13d438fed45577e7b45f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Expanding named entities | |
for entity in doc.ents: | |
print(entity.text, entity.label_) | |
# Analyze syntax | |
print("Noun phrases:", [chunk.text for chunk in doc.noun_chunks]) | |
print("Verbs:", [token.lemma_ for token in doc if token.pos_ == "VERB"]) | |
print("Number of sentences", len([*doc.sents])) | |
print("Sentiment", doc.sentiment) | |
# Understand the length of sentences | |
for sent in doc.sents: | |
print(sent.start_char, sent.end_char, (sent.end_char - sent.start_char)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment