NLP Emotion Detection - Model fails to learn to recognize negations
In general this is a difficult problem, it's about the problem of Natural Language Understanding which is far from being solved.
The advanced option requires a full syntactic parsing of the sentence, ideally followed by some kind of semantic representation of the sentence, for example by extracting relations. As far as I know this is rarely used because these steps will often cause as many errors as they solve.
Some more reasonable heuristics can be considered, for instance detecting specific negation words and either including this information as feature or modifying the original features accordingly (e.g. when a negation is detected replace the token &quot;happy&quot; with &quot;not(happy)&quot; in the features).
Note that it's unlikely to be perfect anyway, due to the usual obstacles: hedging (&quot;I would assume that it was quite good&quot;), sarcasm (&quot;Sure, I was very happy with the terrible service&quot;), metaphors (&quot;I was feeling like a fish in water&quot;), etc.