-1

I have a text file containing clean tweets and after every 15th term I need to insert a period.

In Python how do I add a character after a specific word using regex? Right now I am parsing the line word by word and I don't understand regex enough to write the code.

Basically, so that each line becomes its own string after a period. Or is there an alternative way to split a paragraph into individual sentences.

Silas
  • 179
  • 4
  • 16
  • re.sub("", "", "") – Amey Kumar Samala May 18 '17 at 14:43
  • Can you give an example of input and output? – L3viathan May 18 '17 at 14:43
  • 2
    Please post some code illustrating that at least a minimal effort has been put into this. And why do you need to use regex to do this? It seem problems like this would be solved much easier (and better) with other approaches. – OptimusCrime May 18 '17 at 14:43
  • Can you please Elaborate your question with some example !! – rose May 18 '17 at 14:44
  • regexr (http://regexr.com/) is a really good tool for learning and experimenting with regex. I definitely suggest having a go at it, it'll help with understanding what regex is, what it's used for, and how to apply it. – Xorgon May 18 '17 at 15:31

1 Answers1

-2

Splitting paragraphs into sentences can be achieved with functions in nltk package. Please refer to this answer Python split text on sentences

Community
  • 1
  • 1
quest
  • 3,576
  • 2
  • 16
  • 26