I want to split string based on new line character and replace the new line with a '.' in python. I tried this code but I'm not getting it.
from nltk.tokenize.punkt import PunktSentenceTokenizer, PunktParameters, PunktLanguageVars
ex_sent="Conclusion & Future Work
In our project we have tried for implementing northbound SDN application for OpenFlow protocol evaluation. The client and the RYU application is being connected, via socket connection."
sent_end_chars = (',','\n')
tokenizer = PunktSentenceTokenizer(lang_vars = CommaPoint())
sentences = sentence_splitter.tokenize(ex_sent)
The newline character is
\n. So If you want to replace all new line characters in string with
. you should use
replace() method. In this case:
A second approach is to
.split('\n') by newline and then
'.'.join(your_string). You should checkout the Python documentation.