python - Filter Specific Part of Speech NLTK -


It should be simple, but I'm missing it somehow I have the code:

  import nltk f = open ('... \\ t.txt', 'ru') raw = f.read () token = nltk.word_tokenize (raw) print nltk.pos_tag (token)  

for example:

"[('Process',' NNS '), (' A ',' DT '', 'Sequence', 'NN'

I was wondering how I could just collect everything

('ka', 'den'), ('word', 'nns')]

'N' example in the form of

For areas or all "DT" and "text" itemprop = "text">

You can only remove the tag you want to understand the list, such as:

  & gt; & Gt; Tags = nltk.pos_tag (Token) & Gt; & Gt; & Gt; Dt_tags = [t in tag for [1] == "dt"]> gt; & Gt; DT_tags [('A', 'DT']]  

Comments