Skip to main content

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 {
    locations: Location[];
    positive: number;
    negative: number;
}

with:

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

Location

interface Location {
  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 {
    locations: Location[];
    positive: number;
    negative: number;
}

with:

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

Location

interface Location {
  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,
    "locations": [
        {
            "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.  

Metadata

Release files for wowool-sentiments 2.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for wowool-sentiments 2.1.2
File Interpreter ABI Platform Actions
wowool_sentiments-2.1.2-py3-none-any.whl Python 3 none any Details for wowool_sentiments-2.1.2-py3-none-any.whl

Release files / wowool_sentiments-2.1.2-py3-none-any.whl

Download URL wowool_sentiments-2.1.2-py3-none-any.whl
Size 4.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3dcb4faecdc83b8494cf062aade1006b9e8b4279f05373f15a9cb755fae85b57
BLAKE2b-256 checksum
How to use checksums
02f095dc5feb720f1c328f840348b8e7b89eaf1e1bb008346ee3050c1bb125ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for wowool-sentiments 2.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page