Skip to content

Instantly share code, notes, and snippets.

@James-McNeill
Created July 16, 2021 16:08
Show Gist options
  • Save James-McNeill/7466f004be7b13d438fed45577e7b45f to your computer and use it in GitHub Desktop.
Save James-McNeill/7466f004be7b13d438fed45577e7b45f to your computer and use it in GitHub Desktop.
# 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