本文介绍了脚本是否有一种非常简单的方法来(从上下文中)判断“她"是否来自于其他人?是所有格代词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个脚本来反转一段文本中的所有性别,因此所有性别单词都被交换了-男人"与女人"交换,她"与他"交换,依此类推.关于她"应替换为他"还是他的"的模棱两可.

I am writing a script to reverse all genders in a piece of text, so all gendered words are swapped - "man" is swapped with "woman", "she" is swapped with "he", etc. But there is an ambiguity as to whether "her" should be replaced with "him" or "his".

推荐答案

好的.让我们像语言学家那样看待这个问题.我在这里大声思考.

Okay. Lets look at this like a linguist might. I am thinking aloud here.

""是代词.可以是:

1.所有格代词

2.人称代词

他写了一封信.(间接对象)

He wrote her a letter. (indirect object)

他对进行了感冒治疗.(直接对象)

He treated her for a cold. (direct object)

因此,让我们看一下情况(1),所有格代词.

So lets look at case (1), possessive pronoun. That is it is a pronoun which is in the "genitive" case (meaning, it is a noun which is being "possessive." Okay, that detail isn't quite as important as the next one.)

在这种情况下,她"充当决定因素".限定词可能出现在句子的两个位置(这是一种简化):

In this case, "her" is acting as a "determiner". Determiners may occur in two places in a sentence (this is a simplification):

Det + Adj + Noun(她的好书")

Det + Adj + Noun ("her nice book")

因此要弄清楚她是否是决定者,您可以采用以下逻辑:

So to figure out if her is a determiner, you could have this logic:

a.如果她"后面的单词是名词,那么她"是一个确定词.

b.如果她"后面的两个单词是一个形容词,则是一个名词,那么她"是一个确定词"

如果您确定她"是一个限定词,那么您就知道必须用"his"代替它,后者也是一个限定词(又称宾语名词,又称属格代词).

如果不符合上述条件(a)和(b),则您可能会得出结论,认为它不是,这意味着它一定是人称代词.在这种情况下,您可以将她"替换为他".

If it doesn't match criteria (a) and (b) above, then you could possibly conclude that it is not a determiner, which means it must be a personal pronoun. In that case, you would replace "her" with "him".

您甚至不必进行下面的测试,但是无论如何,我将尽力描述它们.

You wouldn't even have to do the tests below, but I'll try to describe them anyway.

从上面看(2):个人代词,而不是所有格代词.这变得更加棘手.

Looking at (2) from above: personal pronoun, rather than possessive. This gets trickier.

以上示例显示了她"的发生方式有3种:

The examples above show "her" occurring in 3 ways:

(1)将其交给.(介词后.我们称其为介词的对象".)

(1) Give it to her. (after preposition. we call this the "object of a preposition".)

因此,您可以设计一条规则:如果她"在介词之后立即出现,则应将其视为名词,因此我们将其替换为他"."

So you could maybe devise a rule: "If 'her' occurs immediately after a preposition, then it should be treated as a noun, so we would replace it with 'him'".

接下来的两个很棘手. 她"可以是直接对象,也可以是间接对象.

The next two are tricky. "her" can either be a direct object or an indirect object.

(2)他给写了一封信.(间接对象)

(2) He wrote her a letter. (indirect object)

(3)他为感冒了.(直接对象)

(3) He treated her for a cold. (direct object)

从语法上讲,我们该如何区分?

Syntactically, how can we tell the difference?

直接宾语出现在动词之后.

A direct object occurs immediately after a verb.

如果您有一个动词,后接一个名词,那么该名词就是直接宾语.例如:

If you have a verb, followed by a noun, then that noun is a direct object. eg:

他治疗了 .*

如果您有一个动词,一个名词,一个介词短语,那么该名词就是直接宾语.

If you have a verb, followed by a noun, followed by a prepositional phrase, then the noun is a direct object.

他对待为感冒.(她"是一个名词,紧接在动词治疗"之后.感冒"是一个名词介词短语.)

He treated her for a cold. ("her" is a noun, and it comes immediately after the verb "treated". "for a cold" is a prepositional phrase.)

这意味着您可以说如果您有动词+名词+备考",那么该名词就是直接宾语.由于名词是直接宾语,因此它是人称代词,因此请使用他". (请注意,您只需检查一个介词,而不是整个准备词组,因为该词组总是以介词开头.)

Which means that you could say "If you have Verb + Noun + Prep" then the noun is a direct object. Since the noun is a direct object, then it is a personal pronoun, so use "him". (note, you only have to check for a preposition, not the entire prep phrase, since the phrase will always begin with a preposition.)

如果它是一个间接对象,那么您将具有动词+名词+名词"的形式.

If it is an indirect object, then you'll have the form "verb + noun + noun".

他为写了一封信.(她"是一个名词,字母"是一个名词.好吧,一个字母"是名词短语" ,因此您还必须考虑确定者.)

He wrote her a letter. ("her" is a noun, "letter" is a noun. well, "a letter" is a "noun phrase", so you'd have to account for determiners as well.)

因此...如果她"是直接对象,间接对象或prep的obj,则可以将其更改为他",否则,请将其更改为他".

So... if "her" is a direct object, indirect object, or obj of prep, you could change it to "him", otherwise, change it to "his".

此方法似乎要复杂得多-因此,我将首先检查她"是否是决定者(请参见上文),如果是确定者,请使用他的",否则,请使用他". .

This method seems a lot more complicated - so I'd just start by checking to see if "her" is a determiner (see above), and if it is a determiner, use "his" otherwise, just use "him".

因此,上述内容有很多简化.它不包括打断短语",子句结构,选区测试,嵌入子句,标点符号或类似内容.

So, the above has a lot of simplifications. It doesn't cover "interrupting phrases", or clause structures, or constituency tests, or embedded clauses, or punctuation, or anything like that.

此外,此解决方案还需要一个词典-名词",动词"和介词"的列表,以便您可以确定句子中每个单词的词法类别.

Also, this solution requires a dictionary - a list of "nouns" and "verbs" and "prepositions" so that you can determine the lexical category of each word in the sentence.

即使在那儿,人,自然语言处理也很困难.您希望对模型进行某种训练",以得到一个好的解决方案.但是对于非常简单的内容,请尝试上述一些内容.

And even there, man, natural language processing is hard. You'd want to do some sort of "training" for your model to have a good solution. BUT for very simple things, try some of the stuff described above.

很抱歉这么冗长! (现有的答案都没有给出任何硬数据或精确的语言定义,所以去了.)

Sorry for being so verbose! (None of the existing answers gave any hard data, or precise linguistic definitions, so here goes.)

这篇关于脚本是否有一种非常简单的方法来(从上下文中)判断“她"是否来自于其他人?是所有格代词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 22:41