Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create the negative of a sentence in nltk

Tags:

python

nlp

nltk

I am new to NLTK. I would like to create the negative of a sentence (which will usually be in the present tense). For example, is there a function to allow me to convert: 'I run' to 'I do not run'

or

'She runs' to 'She does not run'.

I suppose I could use POS to detect the verb and its preceding pronoun but I just wondered if there was a simpler built in function

like image 401
Sebastian Zeki Avatar asked May 13 '14 14:05

Sebastian Zeki


People also ask

How do you make a statement negative?

In English, we create negative sentences by adding the word 'not' after the auxiliary, or helping, verb. An example of an auxiliary verb is the helping verb 'be. ' There are different forms that 'be' takes, including 'am,' 'is,' 'are,' 'was,' and 'were.


1 Answers

No there is not. What is more important it is quite a complex problem, which can be a topic of research, and not something that "simple built in function" could solve. Such operation requires semantic analysis of the sentence, think about for example "I think that I could run faster" which of the 3 verbs should be negated? We know that "think", but for the algorithm they are just the same. Even the case of detection whether you should use "do" or "does" is not so easy. Consider "Mary and Jane walked down the road" and "Jane walked down the road", without parse tree you won't be able to distinguish the singular/plural problem. To sum up, there is no, and cannot be any simple solution. You can design any kind of heuristic you want (one of such is proposed POS-based negation) and if it fails, start a research in this area.

like image 181
lejlot Avatar answered Sep 28 '22 16:09

lejlot