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
Post a Comment