Skip to content

Instantly share code, notes, and snippets.

@shubham-singh-ss
Last active July 5, 2019 12:21
Show Gist options
  • Save shubham-singh-ss/e0583c56f55f392414fd104f02efc2d4 to your computer and use it in GitHub Desktop.
Save shubham-singh-ss/e0583c56f55f392414fd104f02efc2d4 to your computer and use it in GitHub Desktop.
from spacy.lang.en import English
# Load English tokenizer, tagger, parser, NER and word vectors
nlp = English()
# Create the pipeline 'sentencizer' component
sbd = nlp.create_pipe('sentencizer')
# Add the component to the pipeline
nlp.add_pipe(sbd)
text = """Founded in 2002, SpaceX’s mission is to enable humans to become a spacefaring civilization and a multi-planet
species by building a self-sustaining city on Mars. In 2008, SpaceX’s Falcon 1 became the first privately developed
liquid-fuel launch vehicle to orbit the Earth."""
# "nlp" Object is used to create documents with linguistic annotations.
doc = nlp(text)
# create list of sentence tokens
sents_list = []
for sent in doc.sents:
sents_list.append(sent.text)
sents_list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment