# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
# --------------------------------------------------------------------------------------------
# - Generated by tools/entrypoint_compiler.py: do not edit by hand
"""
Sentiment
"""

__all__ = ["Sentiment"]


from ....entrypoints.transforms_sentimentanalyzer import \
    transforms_sentimentanalyzer
from ....utils.utils import trace
from ...base_pipeline_item import BasePipelineItem, DefaultSignature


class Sentiment(BasePipelineItem, DefaultSignature):
    """

    Scores natural language text and assesses
    the probability the sentiments are positive.

    .. remarks::
        The ``Sentiment`` transform returns the probability that the
        sentiment of a natural text is positive.  The model
        was trained with the :py:class:`WordEmbedding
        <nimbusml.feature_extraction.text.WordEmbedding>` and
        :py:class:`NGramFeaturizer
        <nimbusml.feature_extraction.text.NGramFeaturizer>`
        on Twitter sentiment
        data, similarly to the sentiment analysis part of the `Text Analytics
        cognitive service <https://www.microsoft.com/cognitive-services/en-
        us/text-analytics-api>`_.
        The transform outputs a score between 0 and 1 as a sentiment
        prediction (where 0 is a negative sentiment and 1 is a positive
        sentiment). Currently it
        supports only English.

    :param params: Additional arguments sent to compute engine.

    .. seealso::
        :py:class:`NGramFeaturizer
        <nimbusml.feature_extraction.text.NGramFeaturizer>`,
        :py:class:`WordEmbedding
        <nimbusml.feature_extraction.text.WordEmbedding>`.

    .. index:: transform, text, sentiment, nlp

    Example:
       .. literalinclude:: /../nimbusml/examples/Sentiment.py
              :language: python
    """

    @trace
    def __init__(
            self,
            **params):
        BasePipelineItem.__init__(
            self, type='transform', **params)

    @property
    def _entrypoint(self):
        return transforms_sentimentanalyzer

    @trace
    def _get_node(self, **all_args):
        algo_args = dict(
            source=self.source,
            name=self._name_or_source)

        all_args.update(algo_args)
        return self._entrypoint(**all_args)
