How can I split a text into sentences?

前端 未结 13 1012
傲寒
傲寒 2020-11-22 06:33

I have a text file. I need to get a list of sentences.

How can this be implemented? There are a lot of subtleties, such as a dot being used in abbreviations.

13条回答
  •  既然无缘
    2020-11-22 06:39

    You can try using Spacy instead of regex. I use it and it does the job.

    import spacy
    nlp = spacy.load('en')
    
    text = '''Your text here'''
    tokens = nlp(text)
    
    for sent in tokens.sents:
        print(sent.string.strip())
    

提交回复
热议问题