Splitting on regex without removing delimiters

后端 未结 5 733
花落未央
花落未央 2020-12-11 20:15

So, I would like to split this text into sentences.

s = \"You! Are you Tom? I am Danny.\"

so I get:

[\"You!\", \"Are you To         


        
5条回答
  •  猫巷女王i
    2020-12-11 20:56

    Easiest way is to use nltk.

    import nltk   
    nltk.sent_tokenize(s)
    

    It will return a list of all your sentences without loosing delimiters.

提交回复
热议问题