How to determine subject, object and other words?

后端 未结 5 1137
鱼传尺愫
鱼传尺愫 2021-01-11 17:29

I\'m trying to implement application that can determine meaning of sentence, by dividing it to smaller pieces. So I need to know what words are subject, object etc. so that

5条回答
  •  佛祖请我去吃肉
    2021-01-11 17:39

    You should look at the Natural Language Toolkit, which is for exactly this sort of thing.

    See this section of the manual: Categorizing and Tagging Words - here's an extract:

    >>> text = nltk.word_tokenize("And now for something completely different")
    >>> nltk.pos_tag(text)
    [('And', 'CC'), ('now', 'RB'), ('for', 'IN'), ('something', 'NN'),
    ('completely', 'RB'), ('different', 'JJ')]
    

    "Here we see that and is CC, a coordinating conjunction; now and completely are RB, or adverbs; for is IN, a preposition; something is NN, a noun; and different is JJ, an adjective."

提交回复
热议问题