Skip to main content

The Wowool Sentiment Package

Project description

Sentiment analysis

The sentiments app extracts expressed sentiments from your documents, positive or negative, as well as a percentage of positives and negatives per document.

Names as well as pronouns like he or she are resolved, i.e. He is a nice person. will appear as John Smith is a nice person. in the results.

Results

SentimentsResults

interface SentimentsResults {
    sentiments: SentimentsResult[];
    positive: number;
    negative: number;
}

with:

Property Description
sentiments Sentiments found in the document
positive Percentage of positive sentiments expressed in the document
negative Percentage of negative sentiments expressed in the document

SentimentsResult

interface SentimentsResult {
  polarity: SentimentPolarity;
  text: string;
  begin_offset: number;
  end_offset: number;
  object?: string;
  adjective?: string;
  noun?: string;
  verb?: string;
  expression?: string;
}

with:

Property Description
polarity Polarity of the sentiment
text Literal text of the sentiment
begin_offset Begin offset within the document
end_offset End offset within the document
object Object to which the sentiment refers
adjective When the polarity comes from an adjective, like beautiful
noun When the polarity comes from a noun, like crisis
verb When the polarity comes from a verb, like hate
expression When the polarity comes from an expression, like making waves

SentimentPolarity

type SentimentPolarity = 'positive' | 'negative';

Examples

Sentiment analysis

The sentiments app extracts expressed sentiments from your documents, positive or negative, as well as a percentage of positives and negatives per document.

Names as well as pronouns like he or she are resolved, i.e. He is a nice person. will appear as John Smith is a nice person. in the results.

Results

SentimentsResults

interface SentimentsResults {
    sentiments: SentimentsResult[];
    positive: number;
    negative: number;
}

with:

Property Description
sentiments Sentiments found in the document
positive Percentage of positive sentiments expressed in the document
negative Percentage of negative sentiments expressed in the document

SentimentsResult

interface SentimentsResult {
  polarity: SentimentPolarity;
  text: string;
  begin_offset: number;
  end_offset: number;
  object?: string;
  adjective?: string;
  noun?: string;
  verb?: string;
  expression?: string;
}

with:

Property Description
polarity Polarity of the sentiment
text Literal text of the sentiment
begin_offset Begin offset within the document
end_offset End offset within the document
object Object to which the sentiment refers
adjective When the polarity comes from an adjective, like beautiful
noun When the polarity comes from a noun, like crisis
verb When the polarity comes from a verb, like hate
expression When the polarity comes from an expression, like making waves

SentimentPolarity

type SentimentPolarity = 'positive' | 'negative';

API

Examples

You will need to install the english language module to run the sample. pip install wowool-english

Extracting sentiments

Note that in the results the sentiments have been resolved. For this to happen we need to add the entities in the pipeline.

from wowool.sdk import Pipeline
from wowool.sentiments.app_id import APP_ID

text = "John Dow is a very nice person, but he sucks at football."
pipeline = Pipeline(
    [
        "english",
        "entity",
        "sentiment",
        "sentiments.app",
    ]
)
document = pipeline(text)
print(document.results(APP_ID))

results:

{
    "positive": 50.0,
    "negative": 50.0,
    "sentiments": [
        {
            "polarity": "positive",
            "text": "John Dow is a very nice person",
            "begin_offset": 0,
            "end_offset": 30,
            "object": "John Dow",
            "adjective": "nice"
        },
        {
            "polarity": "negative",
            "text": "John Dow sucks",
            "begin_offset": 36,
            "end_offset": 44,
            "object": "John Dow",
            "expression": "suck",
            "comp": "intrans",
            "verb": "suck"
        }
    ]
}

License

In both cases you will need to acquirer a license file at https://www.wowool.com

Non-Commercial

This library is licensed under the GNU AGPLv3 for non-commercial use.  
For commercial use, a separate license must be purchased.  

Commercial license Terms

1. Grants the right to use this library in proprietary software.  
2. Requires a valid license key  
3. Redistribution in SaaS requires a commercial license.  

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wowool_sentiments-2.0.2-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file wowool_sentiments-2.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for wowool_sentiments-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a091ad2201f4af34d761c815472d9a20fc8690c44cb93b26ebc3566b65598f7d
MD5 1e60d181e13c7b365650f3930d5b5154
BLAKE2b-256 a292fda9ae28cf8a4fc110b23760780cbf17985fb64f4cb842e5f9bcc57f8581

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page