+ 1
How to print the words alone without the pos tag in nltk?!
>>> import nltk >>> o='hello this is my project report' >>> tokens = nltk.word_tokenize(o) >>> print(tokens) ['hello', 'this', 'is', 'my', 'project', 'report'] >>> p=nltk.pos_tag(words) >>> print(p) [('hello', 'NN'), ('this', 'DT'), ('is', 'VBZ'), ('my', 'PRP
#x27;), ('project', 'JJ'), ('report', 'NN')] >>> obj = list(filter(lambda x:x[1]=='NN',p)) >>> print(obj) [('hello', 'NN'), ('report', 'NN')] i need output like [('hello'),('report')]2 Respuestas
+ 1
Not sure if you can get the exact output, as python won't recognise the ('hello') as a tuple without an extra comma in it. i.e ('hello',) unless the nltk (what ever that is) can do it.
print([x for x, y in obj])