A package that provides some small tools for English words.
Project description
Description
wordutilities: A Python package that provides some functions related to English-language words.
Install package:
- Use the following command to install the package:
pip install -i https://test.pypi.org/simple/ wordutilities. - Create a Python program file that imports the package and uses it, e.g.
from wordutilities import wordutilities. - Here are some examples as to how to call each function in the package:
is_anagram("abc","cba")scramble("abc")anagrams("abc")is_blank("abc")permutations("hello")select_random_sentence()select_random_most_common_word()fill_blanks()
- Run the python program.
Function documentation:
Usage examples
is_anagram(word1, word2)
Parameters: word1 and word2 are strings
Return value: a boolean
is_anagram takes as input two strings of characters and determines if they are anagrams of each other; that is, whether you can rearrange the characters in one to get the other.
scramble(word)
Parameters: word is a string
Return value: a string
scramble takes as input a string of characters and permutes these characters into a random order, before returning this new scrambled string
anagrams(word)
Parameters: word is a string (should only contain English letters)
Return value: a sorted list of strings
anagrams takes as input a string of letters and returns all English words which anagram to those letters
anagrams_blank(word)
Parameters: word is a string (should only contain English letters)
Return value: a sorted list of strings
anagrams_blank takes as input a string of letters and returns all English words which anagram to those letters plus one wild letter (akin to a scrabble blank). For example, anagrams_blank('hell') would return a list containing the words 'hello', 'hells', and 'shell'.
permutations(word)
Parameters: word is a string
Return value: an unsorted list of strings
permutations takes as input a string of characters and returns a list of all possible permutations of those characters. This list does not contain repeated permutations. Users should note permutations grow according to the factorial function which will make this function slow for large strings.
select_random_sentence()
Parameters: None
Return value: a string
Generates and returns a random sentence from a list of predefined sentences
select_random_most_common_word()
Parameters: None
Return value: a string
Generates and returns a random word from a predefined list of the 20 most common words
fill_blanks()
Paramenters: None
Return value: None
Selects a random sentence and replaces a word with a blank. User must guess out of three options the correct answer to fill in the blank. They will be prompted to try again until they either get the correct answer or quit.
Contributing
Set up virtual environment:
- Install pipenv if not already installed.
- Clone the repository.
- Run
pipenv shellin your cloned repository.
Install dependencies:
Run pipenv install in your virtual environment.
Build package:
- Run
python -m buildin the directory wherepyproject.tomlis located. - Verify that the built .tar archive has the correct contents using
tar --list -f dist/wordutilities-[version number].tar.gz
Test package:
- Install pytest
- Run
python3 -m pytestin the project directory.
Teammates
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wordutilities-0.1.5.tar.gz.
File metadata
- Download URL: wordutilities-0.1.5.tar.gz
- Upload date:
- Size: 3.5 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41b8db1e72ce2f0f9052dc3c3f6386431fc54f7ad57828cdf618365e16f74f3f
|
|
| MD5 |
e7c33381e1c3dfba895d91362a6904c5
|
|
| BLAKE2b-256 |
016b7e16cb043e6ead588ce387f8ed679e53cae16a4ff25ca2a9fdf00dd38dc2
|
File details
Details for the file wordutilities-0.1.5-py3-none-any.whl.
File metadata
- Download URL: wordutilities-0.1.5-py3-none-any.whl
- Upload date:
- Size: 3.5 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41b247b4c02d3046fc5813fbde0e84627aa9573b86e341806ffdb35a862b3361
|
|
| MD5 |
d5272b68a82923817e1d0a9b0fa53e8b
|
|
| BLAKE2b-256 |
ce7496e1a7d3d2bdeda41dd80adddc30683629decb721a39c1da090269058d9f
|