否定句子的算法

发布于 2024-08-28 09:18:43 字数 171 浏览 5 评论 0原文

我想知道是否有人熟悉算法句子否定的任何尝试。

例如,给定一个句子“这本书很好”,请提供任意数量的意思相反的替代句子,例如“这本书不好”甚至“这本书不好”。

显然,以高精度实现这一点可能超出了当前 NLP 的范围,但我确信在这个主题上已经有了一些工作。如果有人知道任何工作,愿意给我指出一些论文吗?

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 alternative sentences meaning the opposite like "This book is not good" or even "This book is bad".

Obviously, accomplishing this with a high degree of accuracy would probably be beyond the scope of current NLP, but I'm sure there has been some work on the subject. If anybody knows of any work, care to point me to some papers?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

奶茶白久 2024-09-04 09:18:43

虽然我不知道有任何专门研究自动生成否定句子的工作,但我想一个好的起点是阅读 形式语义语用学Steven C. Levinson 的语用学一书是一本很好理解的介绍。

我认为您会遇到的一个问题是,否定句子所传达的所有信息可能非常困难。例如,

John fixed the vase that he broke.

即使您将其更改为约翰没有修理他打破的花瓶,也有一个预设 有一个花瓶并且约翰打破了它。

同样,简单地否定“约翰没有停止使用毒品”这句话,因为“约翰停止使用毒品”仍然传达了约翰曾经使用过毒品。更彻底的否定是约翰从未吸毒

您可能想要查看的一些现有自然语言处理 (NLP) 工作是 MacCartney 和 Manning 2007 的 文本推理的自然逻辑。在本文中,他们使用 George Lakoff 的自然逻辑概念和 Sanchez Valencia 的单调性演算来创建自动确定一个句子是否包含另一个句子的软件。您可能可以使用他们的一些技术来检测非蕴涵,从而人为地构建否定和矛盾的句子。

While I'm not aware of any work that specifically looks at automatically generating negated sentences, I imagine a good place to start would be to read up on linguistics work in formal semantics and pragmatics. A good accessible introduction would be Steven C. Levinson's Pragmatics book.

One issue that I think you'll run into is that it can be very difficult to negate all the information that is conveyed by a sentence. For example, take:

John fixed the vase that he broke.

Even if you change this to John did not fix the vase that he broke, there is a presupposition that there is a vase and that John broke it.

Similarly, simply negating the sentence John did not stopped using drugs as John stopped using drugs still conveys that John, at one point, used drugs. A more thorough negation would be John never used drugs.

Some existing natural language processing (NLP) work that you might want to look at is MacCartney and Manning 2007's Natural Logic for Textual Inference. In this paper they use George Lakoff's notion of Natural Logic and Sanchez Valencia's monotonicity calculus to create software that automatically determines whether one sentence entails another. You could probably use some their techniques for detecting non-entailment to artificially construct negated and contradicting sentences.

小傻瓜 2024-09-04 09:18:43

我建议您查看 wordnet。您可以使用它来查找单词的反义词,因此您可以想象用“不好”替换“坏”,因为坏是好的反义词。 NLTK 具有wordnet 的简单 python 接口。

I'd recommend checking out wordnet. You can use it to lookup antonyms for a word, so you could conceivably replace "bad" with "not good" since bad is an antonym of good. NLTK has a simple python interface to wordnet.

骄傲 2024-09-04 09:18:43

当然,最简单的方法是尝试在 {am,are,is} 之后添加“not”。我不知道这在你的设置中如何工作,它可能只适用于类似谓词的句子。

The naïve way of course, is to try to add "not" right after {am,are,is}. I have no idea how this will work in your setting though, it will probably only work with predicate-like sentences.

贪恋 2024-09-04 09:18:43

对于简单的句子,根据英语语法规则解析寻找副词或形容词,如果仅存在一种含义,则替换反义词。否则使用正确的英语否定规则来否定动词(即:is -> is not)。

高级算法:

  1. 查找每个单词的类型(名词、动词、形容词、副词、连词等)
  2. 从单词类型序列推断句子结构(您的句子是:文章、名词、动词、形容词/副词;这已知是一个简单的句子。)
  3. 对于简单的句子,选择一个可倒装词并将其倒装。要么使用反义词,要么否定动词。

对于更复杂的句子,例如带有从句的句子,您将需要进行更复杂的分析,但对于简单的句子,这不应该是不可行的。

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.

苍风燃霜 2024-09-04 09:18:43

一阶逻辑也有类似的过程。通常的算法是将P映射到not P,然后执行有效的翻译以将not移动到方便的地方,例如:

Original:    (not R(x) => exists(y) (O(y) and P(x, y)))
Negate it:   not (not R(x) => exists(y) (O(y) and P(x, y)))
Rearrange:   not (R(x) or exists(y) (O(y) and P(x, y)))
             not R(x) and not exists(y) (O(y) and P(x, y))
             not R(x) and forall(y) not (O(y) and P(x, y))
             not R(x) and forall(y) (not O(y) or not P(x, y))

执行相同的英语中,你会否定“如果这里不下雨,那么有一些活动是户外活动,可以在这里进行”到“情况不是这样……”最后变成“现在没有下雨,而且每个可能的活动要么不适合户外,要么不能在这里进行。”

当然,自然语言比一阶逻辑复杂得多……但是如果你能将句子解析成可以识别单词“不”、“和”、“或”、“存在”等的东西,那么您应该能够执行类似的翻译。

There's a similar process for first-order logic. The usual algorithm is to map P to not P, and then perform valid translations to move the not somewhere convenient, e.g.:

Original:    (not R(x) => exists(y) (O(y) and P(x, y)))
Negate it:   not (not R(x) => exists(y) (O(y) and P(x, y)))
Rearrange:   not (R(x) or exists(y) (O(y) and P(x, y)))
             not R(x) and not exists(y) (O(y) and P(x, y))
             not R(x) and forall(y) not (O(y) and P(x, y))
             not R(x) and forall(y) (not O(y) or not P(x, y))

Performing the same on English you'd be negating "If it's not raining here, then there is some activity that is an outdoors activity and can be performed here" to "It is NOT the case that ..." and finally into "It's not raining and every possible activity is either not for outdoors or can't be performed here."

Natural language is a lot more complicated than first-order logic, of course... but if you can parse the sentence into something where the words "not", "and", "or", "exists" etc. can be identified, then you should be able to perform similar translations.

寂寞清仓 2024-09-04 09:18:43

对于基于规则的否定方法,您可以查看Python模块否定1

1免责声明:我是该模块的作者。

至于与该主题相关的一些论文,您可以查看:

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.

As for some papers related to the topic, you can take a look at:

葵雨 2024-09-04 09:18:43

使用 NTLK 的精彩演示 - http://text-processing.com/demo 和简短的文章 - http://text-processing.com/demo/sentiment/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文