A sparv plugin for classificating emotions in Swedish text.
Project description
sparv-sbx-emotions-kb-emoclass
Plugin to Sparv plugin to annotate sentences, paragraphs and texts with emotional classification.
Install
First, install Sparv as suggested,
with pipx:
pipx install sparv
or, with uv-pipx:
uvpipx install sparv
Then install install sparv-sbx-emotions-kb-emoclass with,
if you used pipx above:
pipx inject sparv sparv-sbx-emotions-kb-emoclass
or, if you used uv-pipx above:
uvpipx install sparv-sbx-emotions-kb-emoclass --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_emotions_kb_emoclass.sentence-emotion--kb-emoclass
To use it together with other annotations you might add it under export:
export:
annotations:
- <sentence>:sbx_emotions_kb_emoclass.sentence-emotion--kb-emoclass
...
Configuration
You can configure this plugin in the following ways.
Language of Annotations
The language of the annotations defaults to en (English), but you can change that to sv (Swedish).
# file: config.yaml
sbx_emotions_kb_emoclass:
annotation_lang: sv
Metadata
Model
| Type | HuggingFace Model | Revision |
|---|---|---|
| Model | KBLab/emotional-classification |
73f1663770e79ff5c1aa12a38063a13537a02ce0 |
Known issues
InconsistentWarningbecause of usingscikit-learnof version1.7.2. See Issue 11.- Solved with:
scikit-learn<1.3.0andnumpy<2.0.0
- Solved with:
[!NOTE] You might need to put
export CFLAGS="-Wno-error=incompatible-pointer-types" ; export CXXFLAGS="-Wno-error=incompatible-pointer-types"before installing
Minimum Supported Python Version Policy
The Minimum Supported Python Version is fixed for a given minor (1.x) version. However it can be increased when bumping minor versions, i.e. going from 1.0 to 1.1 allows us to increase the Minimum Supported Python Version. Users unable to increase their Python version can use an older minor version instead. Below is a list of sparv-sbx-emotions-kb-emoclass versions and their Minimum Supported Python Version:
- v0.1: Python 3.11.
Note however that sparv-sbx-emotions-kb-emoclass also has dependencies, which might have different MSPV policies. We try to stick to the above policy when updating dependencies, but this is not always possible.
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):
git clone git@github.com:spraakbanken/sparv-sbx-emotions-kb-emoclass.gitgit clone https://github.com/spraakbanken/sparv-sbx-emotions-kb-emoclass.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-txt
This repo uses conventional commits.
Release a new version
sparv-sbx-sentence-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/utilityto 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_emotions_kb_emoclass-0.1.0.tar.gz.
File metadata
- Download URL: sparv_sbx_emotions_kb_emoclass-0.1.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ba4510c799974d08024d6644298d7efc57114ed59bee0527163523b3b070529
|
|
| MD5 |
b5d4e851f07e31cdc2fd41b5f4531c7f
|
|
| BLAKE2b-256 |
98fc262e9902732c5ada16d6a807032ed59154feeda94df0318831fde62e1f36
|
File details
Details for the file sparv_sbx_emotions_kb_emoclass-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sparv_sbx_emotions_kb_emoclass-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
48f714c23c5c06b8916f2412a301f708370b0575c39b71bde77487d63ef4d1d2
|
|
| MD5 |
13825ab07d3689d85cf35f70b427314a
|
|
| BLAKE2b-256 |
772bfc3c06f63e693869e75d6c368fda75ba1c1b430c2f72a3e8009d72a24a11
|