#!/usr/bin/env python3
print("Content-type: text/html\n\n")
print("Test by SG")
import nltk
nltk.download('punkt')
nltk.download('averaged_perceptron_tagger')
lines = 'I was running around in the road then saw a bus'
is_noun = lambda pos:pos[:2] == 'NN'
tokenized = nltk.word_tokenize(lines)
nouns = [word for (word, pos) in nltk.pos_tag(tokenized) if is_noun(pos)]
print (nouns)
I am only getting output:
Test by SG Content-Type: text/html
but the output should be:
['road', 'bus']
I am not getting the correct output.