Articles → NLP → Text Segmentation In Spacy
Text Segmentation In Spacy
Purpose
Example
import spacy
nlp = spacy.load("en_core_web_sm")
# disable parser so sentencizer controls sentence boundaries
nlp.disable_pipes("parser")
# add sentencizer with custom punctuation
nlp.add_pipe(
"sentencizer",
config={"punct_chars": [".", "!", "?", ";"]},
first=True
)
doc = nlp("Hello world; how are you? I am fine.")
for sent in doc.sents:
print(sent)
Output
| Posted By - | Karan Gupta |
| |
| Posted On - | Tuesday, January 6, 2026 |