Search code examples
pythonpython-3.xnltkwordnetpos-tagger

How to get Only Part of speech From POS_TAG in python


Hi every body I wan to get Pos_tag only like "jj" etc of a word . how to get this from list of post_tag . I am able to print this result :

list1=nltk.pos_tag(words)
print(list1)
>>[('good', 'JJ')]

Now My question is now to separate word and post tag from the above result list. I want to store word in myword variable and jj to mypos variable Please store good and jj into two different variable and print separate


Solution

  • I think you need this:

    myword = list[0][0]
    mypos = list[0][1]
    

    Output:

    good
    JJ