python - Handling negation in words -


i have bunch of strings like

i don’t book 

and need below. how obtain this

i not book 

you need this:

replacement = {"n't": " not", "book":"notebook"} string = raw_input("enter sentence: ")  rplc in replacement:     string = string.replace(rplc, replacement[rplc])  print string 

works below:

>>> ================================ restart ================================ >>>  enter sentence: isn't book not notebook >>>  

add want replaced replacement variable.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -