Text_translation / model_spacy.py
Didier's picture
Removing pip install deep_translator install line
690d91f
raw
history blame contribute delete
586 Bytes
"""
File: model_spacy.py
Description:
Load a spaCy model (will be used to split a text into sentences)
Author: Didier Guillevic
Date: 2024-03-30
"""
import spacy
model_xx_name = 'xx_sent_ud_sm'
nlp_xx = spacy.load(model_xx_name)
if __name__ == "__main__":
text = """
This is a very long text. Actually, not that long but still made of a few sentences.
"""
sentences = [sent.text.strip() for sent in nlp(text).sents if sent.text.strip()]
print(f"Nb of sentences: {len(sentences)}")
for i, sent in enumerate(sentences):
print(f"{i:2}: {sent}")