A sparv plugin for computing sentiment for sentences.
Project description
sparv-sbx-sentiment-kb-sent
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.gitgit clone https://github.com/spraakbanken/sparv-sbx-sentiment-kb-sent.git
- Setup environment:
make dev - Install
pre-commithooks:pre-commit install
Do your work.
Tasks to do:
- Test the code with
make testormake 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-txtmake 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.mdto your liking. - Add to git:
git add --update - Commit with
git commit -m 'chore(release): prepare release'orcog 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=patchormake bumpversion
- Major:
- Push
mainand tags to GitHub:git push main --tagsormake publish- GitHub Actions workflow will build, test and publish the package to PyPi.
- Add metadata for Språkbanken's resource
- Generate metadata:
make generate-metadata - Upload the files from
assets/metadata/export/sbx_metadata/analysisto https://github.com/spraakbanken/metadata/tree/main/yaml/analysis.
- Generate metadata:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sparv_sbx_sentiment_kb_sent-0.4.1.tar.gz.
File metadata
- Download URL: sparv_sbx_sentiment_kb_sent-0.4.1.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7270bc4c46bacff3168d77464a6709daf314defb39f12c1b5d0c7b109f802a03
|
|
| MD5 |
932f1de76083471eddbd13b91ef32da3
|
|
| BLAKE2b-256 |
02d94d2f9cb29b0ceb1bd0461b727d71f20a1ee4d82869baa19a8556f9f98baa
|
File details
Details for the file sparv_sbx_sentiment_kb_sent-0.4.1-py3-none-any.whl.
File metadata
- Download URL: sparv_sbx_sentiment_kb_sent-0.4.1-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
334680834e0cbd0e09f0a5e948f13ca5a247a9729f1c353241ae2f3199b3f923
|
|
| MD5 |
b77cc0e9d9cd3ba982f24aaa758b525c
|
|
| BLAKE2b-256 |
a0ba0053a7862c4d2f8597dea7021a03ed6fb0e069d686a128b54708ccec6689
|