I'm looking for algorithm or function to negate a sentence, for example: input: "The Belgian kid like chocolate" output: "The Belgian kid doesn't like chocolate" Does anyone knows an Algorithm or ML model to perform this task?
Asked
Active
Viewed 31 times
2 Answers
0
Popular language models can be fine-tuned for this task. This might be a bit of an overkill, but I was personally very impressed by this example of few-shot learning teaching Google T5 model to negate a sentence with a reasonable success rate with just a dozen samples:
Notebook:
https://colab.research.google.com/drive/1r4NYdk47vsayOELyIGMeoR9xGf7PYveE?usp=sharing

dx2-66
- 2,376
- 2
- 4
- 14
0
For a rule-based negation approach, you can take a look at the Python module negate1.
1 Disclaimer: I am the author of the module.

Diego Miguel
- 531
- 4
- 13