How to identify the subject of a sentence?

前端 未结 6 1627
我在风中等你
我在风中等你 2020-12-14 18:53

Can Python + NLTK be used to identify the subject of a sentence? From what I have learned till now is that a sentence can be broken into a head and its dependents. For e.g.

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-14 19:52

    English language has two voices: Active voice and passive voice. Lets take most used voice: Active voice.

    It follows subject-verb-object model. To mark the subject, write a rule set with POS tags. Tag the sentence I[NOUN] shot[VERB] an elephant[NOUN]. If you see the first noun is subject, then there is a verb and then there is an object.

    If you want to make it more complicated, a sentence- I shot an elephant with a gun. Here the prepositions or subordinate conjunctions like with, at, in can be given roles. Here the sentence will be tagged as I[NOUN] shot[VERB] an elephant[NOUN] with[IN] a gun[NOUN]. You can easily say that word with gets instrumentative role. You can build a rule based system to get role of every word in the sentence.

    Also look at the patterns in passive voice and write rules for the same.

提交回复
热议问题