Skip to content

Instantly share code, notes, and snippets.

@carlfm01
Created September 5, 2019 21:18
Show Gist options
  • Save carlfm01/5acc0ff57900e151aa3783b5cd550a97 to your computer and use it in GitHub Desktop.
Save carlfm01/5acc0ff57900e151aa3783b5cd550a97 to your computer and use it in GitHub Desktop.
Sentences
import spacy
from spacy import displacy
from spacy.lang.es.examples import sentences
f = open("result.txt", mode="w+", encoding="utf-8")
with open('data.txt', mode="r", encoding="utf-8") as file:
data = file.read().replace('\n', '')
nlp = spacy.load('es_core_news_sm', disable=['ner', 'textcat'])
doc = nlp(data)
for sent in doc.sents:
#print('{0}{1}'.format(sent.text, '\n'))
f.write('{0}{1}'.format(sent.text, '\n'))
f.close()
print('Done.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment