1
웹 사이트에서 http://nltk.googlecode.com/svn/trunk/doc/book/ch05.html 나는 태그가있는 자료에서 태그가있는 단어를 나누는 것에 대해 알게되었습니다. 웹 사이트에서nltk를 사용하여 단어를 빼기
코드 : 여기에
>>> sent = '''
... The/AT grand/JJ jury/NN commented/VBD on/IN a/AT number/NN of/IN
... other/AP topics/NNS ,/, AMONG/IN them/PPO the/AT Atlanta/NP and/CC
... Fulton/NP-tl County/NN-tl purchasing/VBG departments/NNS which/WDT it/PPS
... said/VBD ``/`` ARE/BER well/QL operated/VBN and/CC follow/VB generally/RB
... accepted/VBN practices/NNS which/WDT inure/VB to/IN the/AT best/JJT
... interest/NN of/IN both/ABX governments/NNS ''/'' ./.
... '''
>>> [nltk.tag.str2tuple(t) for t in sent.split()]
[('The', 'AT'), ('grand', 'JJ'), ('jury', 'NN'), ('commented', 'VBD'),
('on', 'IN'), ('a', 'AT'), ('number', 'NN'), ... ('.', '.')]
내가 태그 단어의 목록을 얻을. 내가 원하는 건 단어 만 들어있는 목록이다. 예를 들어 :
[('The'), ('grand'), ('jury')...
대신
('The', 'AT'), ('grand', 'JJ'), ('jury', 'NN')...
어떤 제안
의 내가 어떻게이 구할 수 있습니까?미리 감사드립니다.
실제로 OP의 예에는 one-tuple이 없습니다. '('The') == 'The''. –
@larsmans : 네가 맞아, 고마워! –