How to use the textblob.decorators.cached_property function in textblob

To help you get started, we’ve selected a few textblob examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github markuskiller / textblob-de / textblob_de / blob.py View on Github external
    @cached_property
    def noun_phrases(self):
        """Returns a list of noun phrases for this blob."""
        return WordList([phrase.strip()
                         for phrase in self.np_extractor.extract(self.raw)
                         if len(phrase.split()) > 1])
github markuskiller / textblob-de / textblob_de / blob.py View on Github external
    @cached_property
    def sentiment(self):
        """Return a tuple of form (polarity, subjectivity ) where polarity
        is a float within the range [-1.0, 1.0] and subjectivity is a float
        within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is
        very subjective.

        :rtype: named tuple of the form ``Sentiment(polarity=0.0, subjectivity=0.0)``
        """
        #: Enhancement Issue #2
        #: adapted from 'textblob.en.sentiments.py'
        #: Return type declaration
        _RETURN_TYPE = namedtuple('Sentiment', ['polarity', 'subjectivity'])
        _polarity = 0
        _subjectivity = 0
        for s in self.sentences:
            _polarity += s.polarity
github markuskiller / textblob-de / textblob_de / blob.py View on Github external
    @cached_property
    def subjectivity(self):
        '''Return the subjectivity score as a float within the range [0.0, 1.0]
        where 0.0 is very objective and 1.0 is very subjective.

        :rtype: float
        '''
        return self.sentiment[1]
github sloria / TextBlob / textblob / blob.py View on Github external
    @cached_property
    def synsets(self):
        """The list of Synset objects for this Word.

        :rtype: list of Synsets

        .. versionadded:: 0.7.0
        """
        return self.get_synsets(pos=None)
github markuskiller / textblob-de / textblob_de / blob.py View on Github external
    @cached_property
    def synsets(self):
        """The list of Synset objects for this Word.

        :rtype: list of Synsets

        .. versionadded:: 0.7.0 (``textblob``)

        """
        # return self.get_synsets(pos=None)
        raise NotImplementedError
github sloria / TextBlob / textblob / blob.py View on Github external
    @cached_property
    def np_counts(self):
        """Dictionary of noun phrase frequencies in this text.
        """
        counts = defaultdict(int)
        for phrase in self.noun_phrases:
            counts[phrase] += 1
        return counts
github sloria / TextBlob / textblob / classifiers.py View on Github external
    @cached_property
    def classifier(self):
        """The classifier."""
        try:
            return self.train()
        except AttributeError:  # nltk_class has not been defined
            raise ValueError("NLTKClassifier must have a nltk_class"
                            " variable that is not None.")
github markuskiller / textblob-de / textblob_de / blob.py View on Github external
    @cached_property
    def pos_tags(self):
        """Returns an list of tuples of the form (word, POS tag).

        Example:
        ::

            [('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'),
                    ('Thursday', 'NNP'), ('morning', 'NN')]

        :rtype: list of tuples

        """
        return [(Word(word, pos_tag=t), unicode(t))
                for word, t in self.pos_tagger.tag(self.raw)
                # new keyword PatternTagger(include_punc=False)
github sloria / TextBlob / textblob / blob.py View on Github external
    @cached_property
    def noun_phrases(self):
        """Returns a list of noun phrases for this blob."""
        return WordList([phrase.strip().lower()
                        for phrase in self.np_extractor.extract(self.raw)
                        if len(phrase) > 1])
github sloria / TextBlob / textblob / blob.py View on Github external
    @cached_property
    def tokens(self):
        """Return a list of tokens, using this blob's tokenizer object
        (defaults to :class:`WordTokenizer `).
        """
        return WordList(self.tokenizer.tokenize(self.raw))