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

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -