word4num


Nameword4num JSON
Version 0.0.5 PyPI version JSON
download
home_pageNone
SummarySmall library for encoding numbers to words and decoding it back.
upload_time2024-10-05 17:42:43
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords decode words encode number what3words word number converter
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # word4num
Small library for encoding numbers to words and decoding it back. What can be encoded - any short code, phone number, decimal degrees geolocation, ip address etc.
Please share thoughts, ideas and suggestions and feel free to contact me.
## Installation
```sh
# install from PyPI
pip install word4num
```

## Idea
Define a unified mapping from number to words and promote single configuration for similar use cases that combination of words will work in the same way. 
For example: words combination generated in Google Maps will point to the same location in Apple Maps

## Usage
Simple use:
```python
import word4num
# initialise converter:
# '1###' - number mask, # - means that it could be any digit
# 'en' - language (English is only currently supported)
# 4 - max length of one word, could be up to 10
converter=word4num.W4NConverter('1###', 'en', 4)
words=converter.encode_number('1234')
print(converter.decode_words(words[0]))
```
Use with modifiers:
```python
import word4num
# initialise converters:
# '1####' - number mask, # - means that it could be any digit
# 'en' - language (English is only currently supported)
# 5 - max length of one word, could be up to 10
converter=word4num.W4NConverter('1####', 'en', 5)

# in case you don't need a precise number matching and length of words combination is more important
# could be used for decimal degrees geolocation
decreased_precision_converter=word4num.W4NConverter('1####', 'en', 5,lambda x: str(int(int(x)/5)),lambda x: str(int(x)*5) )

# encode same number using both converters
words=converter.encode_number('12344')
decreased_precision_words=decreased_precision_converter.encode_number('12344')

#compare length of words combination
print(len(words[0])>len(decreased_precision_words[0]))

# get decoded numbers
print(converter.decode_words(words[0]))
print(decreased_precision_converter.decode_words(decreased_precision_words[0]))
```

Other methods and available attributes:
```python
import word4num
# initialise converters:
# '1####' - number mask, # - means that it could be any digit
# 'en' - language (English is only currently supported)
# 5 - max length of one word, could be up to 10
converter=word4num.W4NConverter('1####', 'en', 5)

# configured mask
converter.number_mask

#maximum convertible number for configured converter
converter.max_number

#maximum number of words in combination - useful with converter.word_to_num when you want to combine several results of encoding
converter.words_number

#dictionaries of configured converter
converter.word_to_num
converter.num_to_word

#functions that were passed to the converter
converter.modification_to
converter.modification_from
#length of dictionary for configured converter
converter.get_map_length()
```
## Examples
1. examples/4WordsGeo.py :
    Encoding and decoding location in decimal degrees - can be used in new possible substitution of What3Words
    Their solution has problems in dictionary with ambiguously sound words and being proprietary - https://en.wikipedia.org/wiki/What3words
    Use of 4 short and simple words could work better - room for discussion.
    Example: 10.000000, 0.000001 -> ['timid', 'made', 'tip', 'barn']
2. examples/LocalPhoneWords.py :
    Encoding local telephone numbers in UK format into words.
    Example: (027) 4193 2856 -> ['mew', 'atom', 'pick']
3. examples/IntPhoneWords.py :
    Encoding international telephone numbers into words
    Example: (+44) (0)20 7930 4832 -> ['prim', 'enjoy', 'feuds', 'got']

Reasons for 2 and 3 example:
Words Carry Meaning: Words have meaning, context, and imagery associated with them, making them easier to remember. For example, words like "sun", "car", and "tree" evoke clear mental images or associations.
Numbers Are Abstract: An 11-digit number like "12345678901" lacks inherent meaning and context, making it more difficult to recall without using specific memory techniques such as chunking or mnemonics.
Chunking: The brain naturally chunks information for easier recall. While numbers can be chunked (e.g., phone numbers), it's generally easier for the brain to chunk and recall a few meaningful words than a long string of digits.

4. examples/IPv4toWords.py :
    Can be implemented as a simple local DNS for temporarily used IP addresses, JFF (e.g. web browser). Ports can be supported using 4 words.
    Example: 255.255.255.255 -> ['sting', 'year', 'soy']
5. examples/PostcodeWords.py :
    Encoding UK postcodes into 3 words that are easy to remember
    Example: SE10 0TY -> ['neuron', 'toy', 'game']

## Words dictionary generation
1. English words were generated using NLTK using Brown Corpus.
2. Then stop words, proper names, plural words, abbreviations were filtered out to keep only nouns, verbs, adjectives, and adverbs.
3. Words frequencies were used to order list of words.
4. The resulting list was separated to 3,4,5,6,7,8,9,10... letters words to use shortest in some cases.

## TBD
1. Support other languages
2. Add checks and exceptions
3. Add unit tests
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "word4num",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "decode words, encode number, what3words, word number converter",
    "author": null,
    "author_email": "Nikdedov <nik.dedov@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/48/93/7aec2b2ea23e797204480089f35b754847292aa083bfbe180c3950698c01/word4num-0.0.5.tar.gz",
    "platform": null,
    "description": "# word4num\nSmall library for encoding numbers to words and decoding it back. What can be encoded - any short code, phone number, decimal degrees geolocation, ip address etc.\nPlease share thoughts, ideas and suggestions and feel free to contact me.\n## Installation\n```sh\n# install from PyPI\npip install word4num\n```\n\n## Idea\nDefine a unified mapping from number to words and promote single configuration for similar use cases that combination of words will work in the same way. \nFor example: words combination generated in Google Maps will point to the same location in Apple Maps\n\n## Usage\nSimple use:\n```python\nimport word4num\n# initialise converter:\n# '1###' - number mask, # - means that it could be any digit\n# 'en' - language (English is only currently supported)\n# 4 - max length of one word, could be up to 10\nconverter=word4num.W4NConverter('1###', 'en', 4)\nwords=converter.encode_number('1234')\nprint(converter.decode_words(words[0]))\n```\nUse with modifiers:\n```python\nimport word4num\n# initialise converters:\n# '1####' - number mask, # - means that it could be any digit\n# 'en' - language (English is only currently supported)\n# 5 - max length of one word, could be up to 10\nconverter=word4num.W4NConverter('1####', 'en', 5)\n\n# in case you don't need a precise number matching and length of words combination is more important\n# could be used for decimal degrees geolocation\ndecreased_precision_converter=word4num.W4NConverter('1####', 'en', 5,lambda x: str(int(int(x)/5)),lambda x: str(int(x)*5) )\n\n# encode same number using both converters\nwords=converter.encode_number('12344')\ndecreased_precision_words=decreased_precision_converter.encode_number('12344')\n\n#compare length of words combination\nprint(len(words[0])>len(decreased_precision_words[0]))\n\n# get decoded numbers\nprint(converter.decode_words(words[0]))\nprint(decreased_precision_converter.decode_words(decreased_precision_words[0]))\n```\n\nOther methods and available attributes:\n```python\nimport word4num\n# initialise converters:\n# '1####' - number mask, # - means that it could be any digit\n# 'en' - language (English is only currently supported)\n# 5 - max length of one word, could be up to 10\nconverter=word4num.W4NConverter('1####', 'en', 5)\n\n# configured mask\nconverter.number_mask\n\n#maximum convertible number for configured converter\nconverter.max_number\n\n#maximum number of words in combination - useful with converter.word_to_num when you want to combine several results of encoding\nconverter.words_number\n\n#dictionaries of configured converter\nconverter.word_to_num\nconverter.num_to_word\n\n#functions that were passed to the converter\nconverter.modification_to\nconverter.modification_from\n#length of dictionary for configured converter\nconverter.get_map_length()\n```\n## Examples\n1. examples/4WordsGeo.py :\n    Encoding and decoding location in decimal degrees - can be used in new possible substitution of What3Words\n    Their solution has problems in dictionary with ambiguously sound words and being proprietary - https://en.wikipedia.org/wiki/What3words\n    Use of 4 short and simple words could work better - room for discussion.\n    Example: 10.000000, 0.000001 -> ['timid', 'made', 'tip', 'barn']\n2. examples/LocalPhoneWords.py :\n    Encoding local telephone numbers in UK format into words.\n    Example: (027) 4193 2856 -> ['mew', 'atom', 'pick']\n3. examples/IntPhoneWords.py :\n    Encoding international telephone numbers into words\n    Example: (+44) (0)20 7930 4832 -> ['prim', 'enjoy', 'feuds', 'got']\n\nReasons for 2 and 3 example:\nWords Carry Meaning: Words have meaning, context, and imagery associated with them, making them easier to remember. For example, words like \"sun\", \"car\", and \"tree\" evoke clear mental images or associations.\nNumbers Are Abstract: An 11-digit number like \"12345678901\" lacks inherent meaning and context, making it more difficult to recall without using specific memory techniques such as chunking or mnemonics.\nChunking: The brain naturally chunks information for easier recall. While numbers can be chunked (e.g., phone numbers), it's generally easier for the brain to chunk and recall a few meaningful words than a long string of digits.\n\n4. examples/IPv4toWords.py :\n    Can be implemented as a simple local DNS for temporarily used IP addresses, JFF (e.g. web browser). Ports can be supported using 4 words.\n    Example: 255.255.255.255 -> ['sting', 'year', 'soy']\n5. examples/PostcodeWords.py :\n    Encoding UK postcodes into 3 words that are easy to remember\n    Example: SE10 0TY -> ['neuron', 'toy', 'game']\n\n## Words dictionary generation\n1. English words were generated using NLTK using Brown Corpus.\n2. Then stop words, proper names, plural words, abbreviations were filtered out to keep only nouns, verbs, adjectives, and adverbs.\n3. Words frequencies were used to order list of words.\n4. The resulting list was separated to 3,4,5,6,7,8,9,10... letters words to use shortest in some cases.\n\n## TBD\n1. Support other languages\n2. Add checks and exceptions\n3. Add unit tests",
    "bugtrack_url": null,
    "license": null,
    "summary": "Small library for encoding numbers to words and decoding it back.",
    "version": "0.0.5",
    "project_urls": {
        "Homepage": "https://github.com/Nikdedov/word4num",
        "Issues": "https://github.com/Nikdedov/word4num/issues"
    },
    "split_keywords": [
        "decode words",
        " encode number",
        " what3words",
        " word number converter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f1cd9e5530f95a5069726caec7abd8f7717c484bb7ed4e8bb7f9710b9ea424bd",
                "md5": "3cf55b718785132bccbed13673ff2d33",
                "sha256": "7c4bde41732f4b9ca169dba61cea6f1519a2859ec42f20c7321601b7fb2162a3"
            },
            "downloads": -1,
            "filename": "word4num-0.0.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3cf55b718785132bccbed13673ff2d33",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 256376,
            "upload_time": "2024-10-05T17:42:41",
            "upload_time_iso_8601": "2024-10-05T17:42:41.627199Z",
            "url": "https://files.pythonhosted.org/packages/f1/cd/9e5530f95a5069726caec7abd8f7717c484bb7ed4e8bb7f9710b9ea424bd/word4num-0.0.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "48937aec2b2ea23e797204480089f35b754847292aa083bfbe180c3950698c01",
                "md5": "a120cafc91d8edb1c2204c661251a4b3",
                "sha256": "a67349aa1c295806ae4d29cee341137c759fef477641d422e2e5758360233ebd"
            },
            "downloads": -1,
            "filename": "word4num-0.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "a120cafc91d8edb1c2204c661251a4b3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 242398,
            "upload_time": "2024-10-05T17:42:43",
            "upload_time_iso_8601": "2024-10-05T17:42:43.117899Z",
            "url": "https://files.pythonhosted.org/packages/48/93/7aec2b2ea23e797204480089f35b754847292aa083bfbe180c3950698c01/word4num-0.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-05 17:42:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Nikdedov",
    "github_project": "word4num",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "word4num"
}
        
Elapsed time: 0.45517s