Skip to main content

LexoRank reference implementation in Python

Project description

LexoRank4py

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

Installation

Install from PyPI (Recommended)

pip install lexorank4py

Install from source

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

# Install using pip
pip install .

Install in development mode

pip install -e .

Usage

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lexorank4py-0.1.0.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lexorank4py-0.1.0-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file lexorank4py-0.1.0.tar.gz.

File metadata

  • Download URL: lexorank4py-0.1.0.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for lexorank4py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 991f21efddd6c36f09961ed7655415070f43b88a5cf8c6ecbc73a5b15efc4a43
MD5 5d8b723b3a890a626f411c59a840bdc7
BLAKE2b-256 9156d8ae3d1fd51455c674013f901236b09c008a4242363565326f289b71fe11

See more details on using hashes here.

File details

Details for the file lexorank4py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: lexorank4py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for lexorank4py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4c02d2404b2102e3e6da692c0564604ad6d6f984f5558348b2a53f33cea18627
MD5 80510537e77e8d2449bd7175dc985ac3
BLAKE2b-256 07f74114611b813a60f9d70a39efbde5be9094ea18fb33b0f442a5b89f6a0802

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page