Skip to main content

A sparv plugin for computing sentiment for sentences.

Project description

sparv-sbx-sentiment-kb-sent

PyPI version PyPI license PyPI - Python Versions

Maturity badge - level 2 Stage

CI(check) CI(test) CI(scheduled) CI(release) Codecov

Plugin for computing sentiment as a Sparv annotation.

Install

With pipx

First, install Sparv as suggested:

pipx install sparv

Then install install sparv-sbx-sentiment-kb-sent with

pipx inject sparv sparv-sbx-sentiment-kb-sent

With uv-pipx

First, install Sparv as recommended:

uvpipx install sparv

Then install sparv-sbx-sentiment-kb-sent with

uvpipx install sparv-sbx-sentiment-kb-sent --inject sparv

Usage

Depending on how many explicit exports of annotations you have you can decide to use this annotation exclusively by adding it as the only annotation to export under xml_export:

xml_export:
  annotations:
    - <sentence>:sbx_sentiment_kb_sent.sentence-sentiment--kb-sent

To use it together with other annotations you might add it under export:

export:
    annotations:
        - <sentence>:sbx_sentiment_kb_sent.sentence-sentiment--kb-sent
        ...

Configuration

You can configure this plugin in the following way.

Number of Decimals

The number of decimals defaults to 3 but can be configured in config.yaml:

sbx_sentiment_kb_sent:
  num_decimals: 3

[!NOTE] This also controls the cut-off, so all values where the score round to 0.000 (or the number of decimals) is discarded.

Metadata

Model

Type HuggingFace Model Revision
Model KBLab/robust-swedish-sentiment-multiclass b0ec32dca56aa6182a6955c8f12129bbcbc7fdbd
Tokenizer KBLab/megatron-bert-large-swedish-cased-165k 90c57ab49e27b820bd85308a488409dfea25600d

Supported Python versions

This library thrives to support a Python version to End-Of-Life, and will at least bump the minor version when support for a Python version is dropped.

The following versions of this library supports these Python versions:

  • v0.3: Python 3.11
  • v0.2: Python 3.8

Changelog

This project keeps a changelog.

License

This repository is licensed under the MIT license.

Development

Development prerequisites

For starting to develop on this repository:

  • Clone the repo (in one of the ways below): (in one of the ways below):
    • git clone git@github.com:spraakbanken/sparv-sbx-sentiment-kb-sent.git
    • git clone https://github.com/spraakbanken/sparv-sbx-sentiment-kb-sent.git
  • Setup environment: make dev
  • Install pre-commit hooks: pre-commit install

Do your work.

Tasks to do:

  • Test the code with make test or make test-w-coverage.
  • Lint the code with make lint.
  • Check formatting with make check-fmt.
  • Format the code with make fmt.
  • Type-check the code with make type-check.
  • Test the examples with:
    • make test-example-small-txt
    • make test-example-issue-10

This repo uses conventional commits.

Release a new version

sparv-sbx-sentiment-kb-sent

  • Prepare the CHANGELOG: make sparv-sbx-sentiment-kb-sent/CHANGELOG.md.
  • Edit CHANGELOG.md to your liking.
  • Add to git: git add --update
  • Commit with git commit -m 'chore(release): prepare release' or cog commit chore 'prepare release' release.
  • Bump version (depends on `bump-my-version)
    • First cd sparv-sbx-sentiment-kb-sent
    • Major: make bumpversion part=major
    • Minor: make bumpversion part=minor
    • Patch: make bumpversion part=patch or make bumpversion
    • Go back to repo root cd -
  • Push main and tags to GitHub: git push main --tags or make publish
  • Add metadata for Språkbanken's resource

Project details


Download files

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

Source Distribution

sparv_sbx_sentiment_kb_sent-0.4.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

sparv_sbx_sentiment_kb_sent-0.4.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file sparv_sbx_sentiment_kb_sent-0.4.0.tar.gz.

File metadata

File hashes

Hashes for sparv_sbx_sentiment_kb_sent-0.4.0.tar.gz
Algorithm Hash digest
SHA256 511ce9c74003bb4cb6cfd00bcd3eed59b3d607120890da90c37ceb889d3e6b8f
MD5 483b789340e6eacb5d994cfdf70b620a
BLAKE2b-256 6908fbfb707c6f11933e9aaf7464589088499615c803c95ee8a0cd7ef4e93df8

See more details on using hashes here.

File details

Details for the file sparv_sbx_sentiment_kb_sent-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sparv_sbx_sentiment_kb_sent-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 95c96982320fb860299727fc9536a75725c7ab3ebf30b68f7d2c661d4b7733b8
MD5 4643435a31716555a3c8bb6c1df9ca20
BLAKE2b-256 cf8bc54fb0f337b9b20fa1dc1d6509ff727426fd5627011925f172dc143498ab

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