문제

I need an algorithm to tokenize given sentence into words which are correctly tagged to its grammar meaning.

for example: "People took to the streets and protested" people-noun took- adjective and-conjunction to- ...and so on

도움이 되었습니까?

해결책

You mean you want part of speech tagging?

>>> import nltk
>>> tokens = nltk.word_tokenize("People took to the streets and protested")
>>> nltk.pos_tag(tokens)
[('People', 'NNS'), ('took', 'VBD'), ('to', 'TO'), ('the', 'DT'), ('streets', 'NNS'), ('and', 'CC'), ('protested', 'VBD')]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top