semvec/pypi-packages huggingface dataset:
prefix-compression 0.0.1
Shared prefix compression of ordered string sequences.
License: MIT
Keywords: compression development text-processing

# prefix-compression

[![license](https://img.shields.io/github/license/sthagen/python-prefix_compression.svg?style=flat)](https://github.com/sthagen/python-prefix_compression/blob/default/LICENSE)
[![version](https://img.shields.io/pypi/v/prefix-compression.svg?style=flat)](https://pypi.python.org/pypi/prefix-compression/)
[![downloads](https://img.shields.io/pypi/dm/prefix-compression.svg?style=flat)](https://pypi.python.org/pypi/prefix-compression/)
[![wheel](https://img.shields.io/pypi/wheel/prefix-compression.svg?style=flat)](https://pypi.python.org/pypi/prefix-compression/)
[![supported-versions](https://img.shields.io/pypi/pyversions/prefix-compression.svg?style=flat)](https://pypi.python.org/pypi/prefix-compression/)
[![supported-implementations](https://img.shields.io/pypi/implementation/prefix-compression.svg?style=flat)](https://pypi.python.org/pypi/prefix-compression/)

Why not explicitly be weak on naming?

## Status
Experimental

Started using linter, style enforcer, type checker, and coverage in tests.

# what does it accomplish or support?

Provide a memory neutral and fast implementation that is clear to understand and works for the use case of extracting a common prefix of a sequence of strings and yielding that prefix and a generator for the compressed strings of the original sequence.

The latter is not yet clear. One simple implementation path is to receive a reference to a sequence, determine min-max, compare min to max by character and break with first index of enumaeration not matching. Finally yield first the prefix, subsequently all strings of the sequence each shortened by the prefix.

Another still open question is, if a composition of functions can be construed, such that the prefix finding algorithm respects a caller provided policy representing the inner structure of the strings.
 An example for an inner structure is a sequence of paths as strings. A path policy would provide a separator that modifies the prefix finding algorithm to backtrack to the previous such separator token.

why? well, imagine the sequence `'bar/baz', 'bar/bazaar'` and a path policy providing the boolean predicate `lambda x: x == '/'` should not yield `'bar/baz', '', 'aar'` but instead `'bar/', 'baz', 'bazaar'`.

**Note**: The default branch is `default`.

Later we use mkdocs

# Installation

```
$ pipx install prefix-compression
```

# Example Usage

Unshared prefix:
```
$ prefix-compression a/a b/c
Prefix compression yields '' + ['a/a', 'b/c']
```

Shared prefix:
```
$ prefix-compression a/a a/b
Prefix compression yields 'a/' + ['a', 'b']
```

# Change History

## 0.0.1 (2021-05-08)

* Initial release on PyPI