Python NLTK: How to tag sentences with the simplified set of part-of-speech tags?

前端 未结 3 1456
醉酒成梦
醉酒成梦 2020-12-13 18:57

Chapter 5 of the Python NLTK book gives this example of tagging words in a sentence:

>>> text = nltk.word_tokenize(\"And now for something completel         


        
3条回答
  •  天命终不由人
    2020-12-13 20:00

    To simplify tags from the default tagger, you can use nltk.tag.simplify.simplify_wsj_tag, like so:

    >>> import nltk
    >>> from nltk.tag.simplify import simplify_wsj_tag
    >>> tagged_sent = nltk.pos_tag(tokens)
    >>> simplified = [(word, simplify_wsj_tag(tag)) for word, tag in tagged_sent]
    

提交回复
热议问题