nlp - How to slice a sentence like this in Python? -


assuming have sentence "the food not delicious.".

if use traditional method slice sentence words, result may follows:

    "the/food/is/not/delicious/" 

but want slice sentence following:

    "the/food/is/not delicious/" 

the question how realize in python? lot!


sorry decribing quesition breif before, in sentence "the food not delicious", "not delicious" attibute of "food", when slice sentence want let word group "not delicious" go single slot. similarly, assuming have sentence this:

    "mr.lee nice person." 

now, "nice" attribute of person, slicing result is:

    "mr.lee/is/a/nice/person" 

but if change sentence to:

    "mr.lee not nice person." 

i wonder if it's possible slice sentence as:

    "mr.lee/is/a/not nice/person" 

i think difficult problem find out word decorated negative word.

maybe question stupid enough, lot anyway!

in specific case of example, code should work. please detail question if not you.

import re sentence = "the food not delicious" sentence = sentence.replace(' ', '/').replace('/not/', '/not ') 

Comments

Popular posts from this blog

php - Zend Framework / Skeleton-Application / Composer install issue -

c# - Better 64-bit byte array hash -

python - PyCharm Type error Message -