Create a program using NLTK that asks for a word and checks whether it is more frequent as a Noun or a Verb in Brown corpus

39 views Asked by At
import nltk
from nltk.corpus import brown
user=input("Enter a word:")
words=brown.tagged_words()
for word in words:
    if 

I have started like this but I can"t go on

1

There are 1 answers

0
Rusticus On

Just a hint:

print(words[0:9])

will give you:

[('The', 'AT'), ('Fulton', 'NP-TL'), ('County', 'NN-TL'), ('Grand', 'JJ-TL'), ('Jury', 'NN-TL'), ('said', 'VBD'), ('Friday', 'NR'), ('an', 'AT'), ('investigation', 'NN')]

This is a list of tuples, where the first value is the word (token) and the second is the token type.

so you might say:

for word in words:
    if word[0] == user:
        # do something depending on the value of word[1]