Metadata-Version: 2.4
Name: lexorank4py
Version: 0.1.0
Summary: LexoRank reference implementation in Python
Author-email: Luo Fan <luofan036@gmail.com>
License: MIT License
        
        Copyright (c) 2024
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
        
Project-URL: Homepage, https://github.com/luofanlf/lexorank4py
Project-URL: Repository, https://github.com/luofanlf/lexorank4py
Project-URL: Issues, https://github.com/luofanlf/lexorank4py/issues
Keywords: lexorank,ordering,ranking,base36
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# LexoRank4py

LexoRank reference implementation in Python. A library for generating lexicographic ordering strings using base36 encoding.

## Installation

### Install from PyPI (Recommended)

```bash
pip install lexorank4py
```

### Install from source

```bash
# Clone the repository
git clone https://github.com/luofanlf/lexorank4py.git
cd lexorank

# Install using pip
pip install .
```

### Install in development mode

```bash
pip install -e .
```

## Usage

```python
from lexorank import (
    initialize_lexorank,
    get_rank_between,
    get_rank_before,
    get_rank_after,
    rank_to_int,
    int_to_rank,
)

# Initialize ranks for a list of items
ranks = initialize_lexorank(5)
print(ranks)  # ['0', '7', 'e', 'l', 's']

# Get rank between two ranks
rank = get_rank_between("0", "1")
print(rank)  # '08'

# Get rank before (at the head)
rank_before = get_rank_before("a")
print(rank_before)

# Get rank after (at the tail)
rank_after = get_rank_after("z")
print(rank_after)

# Convert between rank strings and integers
rank_str = int_to_rank(100)
int_value = rank_to_int("2s")
```

## API Reference

### `initialize_lexorank(num: int) -> list[str]`

Initialize lexorank strings for a given number of items.

### `get_rank_between(left: str, right: str) -> str`

Get the rank string between two ranks.

### `get_rank_before(right: str) -> str`

Get the rank string before the given rank (for inserting at the head).

### `get_rank_after(left: str) -> str`

Get the rank string after the given rank (for inserting at the tail).

### `rank_to_int(rank: str) -> int`

Convert a lexorank string (base36) to an integer.

### `int_to_rank(value: int) -> str`

Convert an integer to a lexorank string (base36).

### `int_to_rank_with_length(value: int, length: int) -> str`

Convert an integer to a lexorank string with fixed length.

