Algorithm for Negating Sentences

前端 未结 6 658
庸人自扰
庸人自扰 2021-02-12 15:15

I was wondering if anyone was familiar with any attempts at algorithmic sentence negation.

For example, given a sentence like \"This book is good\" provide any number of

6条回答
  •  臣服心动
    2021-02-12 16:05

    For simple sentences parse looking for adverbs or adjectives given the English grammar rules and substitute an antonym if only one meaning exists. Otherwise use the correct English negation rule to negate the verb (ie: is -> is not).

    High level algorithm:

    1. Look up each word for it's type (noun, verb, adjective, adverb, conjunction, etc...)
    2. Infer sentence structure from word type sequences (Your sentence was: article, noun, verb, adjective/adverb; This is known to be a simple sentence.)
    3. For simple sentences, choose one invertible word and invert it. Either by using an antonym, or negating the verb.

    For more complex sentences, such as those with subordinate clauses, you will need to have more complex analysis, but for simple sentences, this shouldn't be infeasible.

提交回复
热议问题