A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://textblob.readthedocs.io/en/dev/_modules/textblob/en/taggers.html below:

textblob.en.taggers — TextBlob 0.19.0 documentation

Source code for textblob.en.taggers
"""Parts-of-speech tagger implementations."""

import nltk

import textblob as tb
from textblob.base import BaseTagger
from textblob.decorators import requires_nltk_corpus
from textblob.en import tag as pattern_tag



[docs]
class PatternTagger(BaseTagger):
    """Tagger that uses the implementation in
    Tom de Smedt's pattern library
    (http://www.clips.ua.ac.be/pattern).
    """


[docs]
    def tag(self, text, tokenize=True):
        """Tag a string or BaseBlob."""
        if not isinstance(text, str):
            text = text.raw
        return pattern_tag(text, tokenize)





[docs]
class NLTKTagger(BaseTagger):
    """Tagger that uses NLTK's standard TreeBank tagger.
    NOTE: Requires numpy. Not yet supported with PyPy.
    """


[docs]
    @requires_nltk_corpus
    def tag(self, text):
        """Tag a string or BaseBlob."""
        if isinstance(text, str):
            text = tb.TextBlob(text)

        return nltk.tag.pos_tag(text.tokens)



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4