semvec/pypi-packages huggingface dataset:
ufo-tools 0.2.2
Python monads for functional programing
Requires Python: >=3.8

# UFO 🛸
*uniform functional orchestrators*

Delicious monads and functional programming patterns in python!

[Check out the api docs for reference](https://benrutter.github.io/ufo-tools/index.html)

![Coverage Badge](https://img.shields.io/badge/coverage-100-green) ![Static Badge](https://img.shields.io/badge/python-%3E%3D3.8-blue)

## Project Goals

This library is meant to implement a simple tools for functional programming in python in a way that:

- Can be intergrated quickly/simply with existing code
- Maintains type safety
- Depends only on the standard library


## Quick Start

Install libary with pip:

```bash
pip install monadcontainers
```

You can now import monad classes for handling functional chains over data.

Say we want to pass a value through a list of functions like so:

```python
def add_six(x: int) -> int:
  return x + 6

def minus_two(x: int) -> int:
  return x - 2

x = minus_two(add_six(4))  # x == 8
```

This can be a little messy with long calls, more importantly monads can handle repeated work for us with each call (but we'll cover that in a sec).

A basic identity Monad implementing the above looks like this:

```python
from monadcontainers.monads import Monad

x = (
  Monad(4)
  .bind(add_six)
  .bind(minus_two)
)  # x == Monad(8)

y = x.value  # y == 8
```

This above pattern chains the Monad contained value through the relevant functions. For alternative syntactical sugar to the `bind` method, you can use `>>`:

```python
x = (
  Monad(4)
  >> add_six
  >> minus_two
)  # x == Monad(8)
```

We can also use Monads to handle additional functionality for us, like error handling with the `Result` monad:

```python
def divide_by_zero(x: int) -> int:
    return x / 0

x = (
  Result(4)
  >> add_six
  >> divide_by_zero
  >> minus_two
)  # x is a result monad

x.unwrap()  # <- raises divide by zero exception
x.unwrap_or(42)  # <- evaluates to 42
x.value  # <- is None (since exception has been raised)
x.exception  # <- is a ZeroDivisionError
x.recover(add_six)  # <- will apply the given function to the last non-error state
```

Monad's can be a helpful pattern for functional programming, see the docs for more info on available Monad classes.

Enjoy! 👍
sparv-word-prediction-kb-bert-plugin 0.5.2
A sparv plugin for computing word neighbours using a BERT model.
Requires Python: >=3.9

# sparv-word-prediction--kb-bert-plugin

[![PyPI version](https://badge.fury.io/py/sparv-word-prediction-kb-bert-plugin.svg)](https://pypi.org/project/sparv-word-prediction-kb-bert-plugin)

Plugin for applying bert masking as a [Sparv](https://github.com/spraakbanken/sparv-pipeline) annotation.

## Install

First, install Sparv, as suggested:

```bash
pipx install sparv-pipeline
```

Then install install `sparv-word-prediction-kb-bert-plugin` with

```bash
pipx inject sparv-pipeline sparv-word-prediction-kb-bert-plugin
```

## 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:
        - <token>:word_prediction_kb_bert.word-prediction--kb-bert
```

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

```yaml
export:
    annotations:
        - <token>:word_prediction_kb_bert.word-prediction--kb-bert
        ...
```

### Configuration

You can configure this plugin by the number of neighbours to generate.

#### Number of Neighbours

The number of neighbours defaults to `5` but can be configured in `config.yaml`:

```yaml
word_prediction_kb_bert:
    num_neighbours: 5
```

#### Number of Decimals

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

```yaml
word_prediction_kb_bert:
    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/bert-base-swedish-cased`](https://huggingface.co/KBLab/bert-base-swedish-cased) | c710fb8dff81abb11d704cd46a8a1e010b2b022c
Tokenizer | same as Model  | same as Model

## Changelog

This project keeps a [changelog](./CHANGELOG.md).