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 sparv-sbx-sentiment-kb-sent with

sparv plugins install sparv-sbx-sentiment-kb-sent

or, you can also 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

sparv plugins install sparv-sbx-sentiment-kb-sent

or, you can also 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.sentiment--kb-sent

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

export:
    annotations:
        - <sentence>:sbx_sentiment_kb_sent.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.4: Python 3.11
  • 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 prepare-release.
  • 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)
    • Major: make bumpversion part=major
    • Minor: make bumpversion part=minor
    • Patch: make bumpversion part=patch or make bumpversion
  • 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.1.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.1-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.1.tar.gz.

File metadata

File hashes

Hashes for sparv_sbx_sentiment_kb_sent-0.4.1.tar.gz
Algorithm Hash digest
SHA256 7270bc4c46bacff3168d77464a6709daf314defb39f12c1b5d0c7b109f802a03
MD5 932f1de76083471eddbd13b91ef32da3
BLAKE2b-256 02d94d2f9cb29b0ceb1bd0461b727d71f20a1ee4d82869baa19a8556f9f98baa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sparv_sbx_sentiment_kb_sent-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 334680834e0cbd0e09f0a5e948f13ca5a247a9729f1c353241ae2f3199b3f923
MD5 b77cc0e9d9cd3ba982f24aaa758b525c
BLAKE2b-256 a0ba0053a7862c4d2f8597dea7021a03ed6fb0e069d686a128b54708ccec6689

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