wordlexord


Namewordlexord JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/lindy2076/words-serial-number
SummaryThis is a python package for having fun with words ordered by length and then lexicographically
upload_time2023-05-31 08:32:29
maintainer
docs_urlNone
authorAleksej Kosolapov
requires_python>=3.10
licenseMIT
keywords words order ordered lexicographically
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # words-serial-number
This is a python package for having ***fun*** with words ordered by **length and** then **lexicographically**.

(eg: `a, b, c, d, e, ..., x, y, z, aa, ab, ac, ..., ax, ay, az, ba, bc, bd` and so on...)

## lore

Each word has it's serial number. For example, if we use standart english alphabet `"abcdefghijklmnopqrstuvwxyz"` and we want to find the **8514**th word in this alphabet - we can just call the `get_word_by_number` method and get the answer - it's **lol**.

We can do the same thing in other direction. If we want to find the serial number of the word `jesus`, we can call the `get_word_number` and recieve the number: it's **4671049**.

There are also **other** helpful methods:
- `get_words_numbers_in_sentence` - as it says, we recieve a list of words' serial numbers from a sentence (string). (`"lol lmao"` -> `[8514, 219741]`)
- `nums_to_words` - same, but in other direction (`[235476151, 18091001]` -> `["sugoma", "amogus"]`)  
- `words_range` - same as python range, but with words. (`1000, 1500, 100` -> `generator("all", "aph", "atd", "awz", "bav")`)
- `infinite_generation` - it just prints all the words starting with the first word in an infinite loop.

## installation
`pip install wordlexord`

## quick start
```python
from word_lexord import (
    lang, get_word_by_number,
    get_word_number,
    get_words_numbers_in_sentence
)

eng_lower = lang.ALPHABETS["EN"]["lower"]

jesus_number = get_word_number("jesus", eng_lower)
print(f"Serial number of the word \"jesus\" is {jesus_number}")
# Serial number of the word "jesus" is 4671049

some_word = get_word_by_number(18091001, eng_lower)
print(f"The word by number {18091001} is {some_word}")
# The word by number 18091001 is amogus

sentence = "hi there! i am using telegram"
print(get_words_numbers_in_sentence(sentence, eng_lower))
# [217, 9283981, 9, 39, 9936895, 162325779031]
```

## docs

### alphabets

Since order can be determined on an alphabet, we will need the alphabet. An alphabet is a string, where each symbol is a letter of the alphabet. There are few alphabets available in the package, they are located in **lang** module. 
```python
from word_lexord import lang

eng_lower = lang.ALPHABETS["EN"]["lower"]
print(eng_lower)  # "abcdefghijklmnopqrstuvwxyz"
```

Or you can just use a string with random symbols:
```python
abc = "12345qwertyuiop" 
```

We will use some alphabets further: english lower and russian lower.

### methods

- `get_word_number(word, alphabet: str) -> int` - get the *word*'s number in *alphabet*.
    
    e.g: `get_word_number("sus", eng_lower)` is `13409`. 

- `get_word_by_number(num: int, alphabet: str) -> str` - get the word by the *num* in *alphabet*.

    e.g: `get_word_by_number(235476151, eng_lower)` is `"sugoma"`.

- `get_words_numbers_in_sentence(sentence: str, alphabet: str) -> List[int]` - get each word's number in *sentence*. Words are separated with the space symbol. Each symbol that is not present in 'alphabet' is replaced with the space symbol.

    e.g: `get_words_numbers_in_sentence("i love bioinformatics!", eng_lower)` is `[9, 221629, 5877569419735112053]`. As you can see, the exclamation mark is didn't affect the result.

- `nums_to_words(nums: List[int], alphabet: str) -> List[str]` - convert each num in *nums* into word by `get_word_number`.

    e.g: `nums_to_words([9, 221629, 5877569419735112053], eng_lower)` is `['i', 'love', 'bioinformatics']`.

- `words_range(alphabet: str, *args: List[int]) -> str` - recieve a word generator. *args* works like range() function. It takes from 1 to 3 arguments.

    e.g: 
    ```python
    for word in words_range(eng_lower, 1, 100, 20):
        print(word, eng=" ")
    # a u ao bi cc 
    ```


- `decimal_to_base(num, base: int) -> list[int]` - convert *num* from decimal to *base* number system without zeros.

    e.g: `decimal_to_base(1234, 2)` is `[1, 1, 2, 2, 1, 2, 1, 2, 1, 1]
`.

- `convert_nums_to_letters(nums: List[int], alphabet: str) -> str` - replaces *nums* with list of chars and concatenates them.

    e.g: `convert_nums_to_letters([1, 2, 3], eng_lower)` is `"abc"`.


## todo
- docs
- readme rus
- poetry

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/lindy2076/words-serial-number",
    "name": "wordlexord",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "words,order,ordered,lexicographically",
    "author": "Aleksej Kosolapov",
    "author_email": "Aleksej Kosolapov <kakaporuqee@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/bb/dc/db78cc1f6a736f33e149e3ff14843bf6ada432b21cc5c87107385c04ffac/wordlexord-0.0.2.tar.gz",
    "platform": null,
    "description": "# words-serial-number\nThis is a python package for having ***fun*** with words ordered by **length and** then **lexicographically**.\n\n(eg: `a, b, c, d, e, ..., x, y, z, aa, ab, ac, ..., ax, ay, az, ba, bc, bd` and so on...)\n\n## lore\n\nEach word has it's serial number. For example, if we use standart english alphabet `\"abcdefghijklmnopqrstuvwxyz\"` and we want to find the **8514**th word in this alphabet - we can just call the `get_word_by_number` method and get the answer - it's **lol**.\n\nWe can do the same thing in other direction. If we want to find the serial number of the word `jesus`, we can call the `get_word_number` and recieve the number: it's **4671049**.\n\nThere are also **other** helpful methods:\n- `get_words_numbers_in_sentence` - as it says, we recieve a list of words' serial numbers from a sentence (string). (`\"lol lmao\"` -> `[8514, 219741]`)\n- `nums_to_words` - same, but in other direction (`[235476151, 18091001]` -> `[\"sugoma\", \"amogus\"]`)  \n- `words_range` - same as python range, but with words. (`1000, 1500, 100` -> `generator(\"all\", \"aph\", \"atd\", \"awz\", \"bav\")`)\n- `infinite_generation` - it just prints all the words starting with the first word in an infinite loop.\n\n## installation\n`pip install wordlexord`\n\n## quick start\n```python\nfrom word_lexord import (\n    lang, get_word_by_number,\n    get_word_number,\n    get_words_numbers_in_sentence\n)\n\neng_lower = lang.ALPHABETS[\"EN\"][\"lower\"]\n\njesus_number = get_word_number(\"jesus\", eng_lower)\nprint(f\"Serial number of the word \\\"jesus\\\" is {jesus_number}\")\n# Serial number of the word \"jesus\" is 4671049\n\nsome_word = get_word_by_number(18091001, eng_lower)\nprint(f\"The word by number {18091001} is {some_word}\")\n# The word by number 18091001 is amogus\n\nsentence = \"hi there! i am using telegram\"\nprint(get_words_numbers_in_sentence(sentence, eng_lower))\n# [217, 9283981, 9, 39, 9936895, 162325779031]\n```\n\n## docs\n\n### alphabets\n\nSince order can be determined on an alphabet, we will need the alphabet. An alphabet is a string, where each symbol is a letter of the alphabet. There are few alphabets available in the package, they are located in **lang** module. \n```python\nfrom word_lexord import lang\n\neng_lower = lang.ALPHABETS[\"EN\"][\"lower\"]\nprint(eng_lower)  # \"abcdefghijklmnopqrstuvwxyz\"\n```\n\nOr you can just use a string with random symbols:\n```python\nabc = \"12345qwertyuiop\" \n```\n\nWe will use some alphabets further: english lower and russian lower.\n\n### methods\n\n- `get_word_number(word, alphabet: str) -> int` - get the *word*'s number in *alphabet*.\n    \n    e.g: `get_word_number(\"sus\", eng_lower)` is `13409`. \n\n- `get_word_by_number(num: int, alphabet: str) -> str` - get the word by the *num* in *alphabet*.\n\n    e.g: `get_word_by_number(235476151, eng_lower)` is `\"sugoma\"`.\n\n- `get_words_numbers_in_sentence(sentence: str, alphabet: str) -> List[int]` - get each word's number in *sentence*. Words are separated with the space symbol. Each symbol that is not present in 'alphabet' is replaced with the space symbol.\n\n    e.g: `get_words_numbers_in_sentence(\"i love bioinformatics!\", eng_lower)` is `[9, 221629, 5877569419735112053]`. As you can see, the exclamation mark is didn't affect the result.\n\n- `nums_to_words(nums: List[int], alphabet: str) -> List[str]` - convert each num in *nums* into word by `get_word_number`.\n\n    e.g: `nums_to_words([9, 221629, 5877569419735112053], eng_lower)` is `['i', 'love', 'bioinformatics']`.\n\n- `words_range(alphabet: str, *args: List[int]) -> str` - recieve a word generator. *args* works like range() function. It takes from 1 to 3 arguments.\n\n    e.g: \n    ```python\n    for word in words_range(eng_lower, 1, 100, 20):\n        print(word, eng=\" \")\n    # a u ao bi cc \n    ```\n\n\n- `decimal_to_base(num, base: int) -> list[int]` - convert *num* from decimal to *base* number system without zeros.\n\n    e.g: `decimal_to_base(1234, 2)` is `[1, 1, 2, 2, 1, 2, 1, 2, 1, 1]\n`.\n\n- `convert_nums_to_letters(nums: List[int], alphabet: str) -> str` - replaces *nums* with list of chars and concatenates them.\n\n    e.g: `convert_nums_to_letters([1, 2, 3], eng_lower)` is `\"abc\"`.\n\n\n## todo\n- docs\n- readme rus\n- poetry\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "This is a python package for having fun with words ordered by length and then lexicographically",
    "version": "0.0.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/lindy2076/words-serial-number/issues",
        "Download": "https://github.com/lindy2076/words-serial-number/issues",
        "Homepage": "https://github.com/lindy2076/words-serial-number"
    },
    "split_keywords": [
        "words",
        "order",
        "ordered",
        "lexicographically"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e01918ec19a49cf9769ac954a0b40e3fd24a315d26a862b25141d42b5ba0a5f6",
                "md5": "42d1a38a9dae4e70de2098d9672acd21",
                "sha256": "9971a9f8ff86c9d5e58fba9ca99fb37a068e542b68f805289dad6db8fb7c5f4d"
            },
            "downloads": -1,
            "filename": "wordlexord-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "42d1a38a9dae4e70de2098d9672acd21",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 6888,
            "upload_time": "2023-05-31T08:32:26",
            "upload_time_iso_8601": "2023-05-31T08:32:26.509247Z",
            "url": "https://files.pythonhosted.org/packages/e0/19/18ec19a49cf9769ac954a0b40e3fd24a315d26a862b25141d42b5ba0a5f6/wordlexord-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bbdcdb78cc1f6a736f33e149e3ff14843bf6ada432b21cc5c87107385c04ffac",
                "md5": "8f71a3ecd89f308d16ca13d74e62156a",
                "sha256": "167fcada1b0ec03001b7eef74d103e642e7940c8968cdaa16bb3ee185d1166f1"
            },
            "downloads": -1,
            "filename": "wordlexord-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "8f71a3ecd89f308d16ca13d74e62156a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 6642,
            "upload_time": "2023-05-31T08:32:29",
            "upload_time_iso_8601": "2023-05-31T08:32:29.665194Z",
            "url": "https://files.pythonhosted.org/packages/bb/dc/db78cc1f6a736f33e149e3ff14843bf6ada432b21cc5c87107385c04ffac/wordlexord-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-31 08:32:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lindy2076",
    "github_project": "words-serial-number",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "wordlexord"
}
        
Elapsed time: 0.07505s