Metadata-Version: 2.4
Name: sparv-sbx-sentence-sentiment-kb-sent
Version: 0.3.0
Summary: A sparv plugin for computing sentence sentiment.
Project-URL: Homepage, https://spraakbanken.gu.se
Project-URL: Repository, https://github.com/spraakbanken/sparv-sbx-sentence-sentiment-analysis
Project-URL: Bug Tracker, https://github.com/spraakbanken/sparv-sbx-sentence-sentiment-analysis/labels/project%3Asentence-sentiment--kb-sent
Author-email: Språkbanken Text <sb-info@svenska.gu.se>, Kristoffer Andersson <kristoffer.andersson@gu.se>
License-Expression: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Utilities
Requires-Python: >=3.11
Requires-Dist: sparv>=5.3.1
Requires-Dist: transformers>=4.56.1
Description-Content-Type: text/markdown

# sparv-sbx-sentence-sentiment-kb-sent

[![PyPI version](https://badge.fury.io/py/sparv-sbx-sentence-sentiment-kb-sent.svg)](https://pypi.org/project/sparv-sbx-sentence-sentiment-kb-sent)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/sparv-sbx-sentence-sentiment-kb-sent)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/sparv-sbx-sentence-sentiment-kb-sent)](https://pypi.org/project/sparv-sbx-sentence-sentiment-kb-sent/)

[![Maturity badge - level 2](https://img.shields.io/badge/Maturity-Level%202%20--%20First%20Release-yellowgreen.svg)](https://github.com/spraakbanken/getting-started/blob/main/scorecard.md)
[![Stage](https://img.shields.io/pypi/status/sparv-sbx-sentence-sentiment-kb-sent)](https://pypi.org/project/sparv-sbx-sentence-sentiment-kb-sent/)

[![CI(release)](https://github.com/spraakbanken/sparv-sbx-sentiment-analysis/actions/workflows/release-sentence-sentiment-kb-sent.yml/badge.svg)](https://github.com/spraakbanken/sparv-sbx-sentiment-analysis/actions/workflows/release-sentence-sentiment-kb-sent.yml)

Plugin for computing sentence sentiment as a [Sparv](https://github.com/spraakbanken/sparv-pipeline) annotation.

## Install

### With [pipx](https://pipx.pypa.io/latest/)

First, install Sparv as suggested:

```bash
pipx install sparv
```

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

```bash
pipx inject sparv sparv-sbx-sentence-sentiment-kb-sent
```

### With [uv-pipx](https://github.com/pytgaen/uv-pipx)

First, install Sparv as recommended:

```shell
uvpipx install sparv
```

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

```shell
uvpipx install sparv-sbx-sentence-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`:

```yaml
xml_export:
  annotations:
    - <sentence>:sbx_sentence_sentiment_kb_sent.sentence-sentiment--kb-sent
```

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

```yaml
export:
    annotations:
        - <sentence>:sbx_sentence_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`:

```yaml
sbx_sentence_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`](https://huggingface.co/KBLab/robust-swedish-sentiment-multiclass)       | b0ec32dca56aa6182a6955c8f12129bbcbc7fdbd |
| Tokenizer | [`KBLab/megatron-bert-large-swedish-cased-165k`](https://huggingface.co/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](./CHANGELOG.md).

## License

This repository is licensed under the [MIT](./LICENSE) license.
