A motley trove of word algorithms I've enjoyed.
qrtḥdšt = carthago = new town
carthago nova = cartagena = new new town
neo cartagena = new new new town
Requires pipenv
pip install --user pipenv;
pipenv install;
pipenv install --dev;
Pipenv based to minimize system python interference.
pipenv run mypy ./*.py # typechecker
pipenv run python ./main.py <mode> <args> # cli
pipenv run uvicorn app:app --reload # fastapi server
Command line and rest interfaces.
http://127.0.0.1:8000/redoc
http://127.0.0.1:8000/openapi.json
Swagger and redoc came for free with fastAPI.
pipenv run st run --checks all --experimental=openapi-3.1 --hypothesis-max-examples=10 http://127.0.0.1:8000/openapi.json
Based on schemathesis (the run st
bit)
pipenv run python ./main.py solve-anagram <word>
Solve an anagram and provide a scrabble score for each solution. TODO: fix grinding slowness for larger words TODO: consider a scrabble dictionary for scoring and far less noisy dictionary for general purpose
pipenv run python ./main.py compute-distance <word1> <word2>
Compute the edit distance (Levenshtein distance) between two words.
pipenv run python ./main.py cats-conundrum
Solve an anagram in the style of a conundrum from "8 out of 10 Cats Does Countdown" TODO: Write clues that are relevant to both the anagram and the solution.
pipenv run python ./main.py find-rhymes <word>
Find words that rhyme with the input word.
TODO: More nuanced rhymes are needed than last 2 phonetics, because words like toxic
and taco
give too much noise while short words like stirred
seem to do well.
pipenv run python ./main.py pig-latin <word>
Translate the input word into pig latin.
TODO: use the phonetics stuff from rhyming to translate words beginning with digraphs like charlie
and phoebe
into arliechay
and oebephay
instead of harliecay
and hoebepay
pipenv run python ./main.py solve-anagram bird;
pipenv run python ./main.py compute-distance bird taco;
pipenv run python ./main.py find-rhymes bird;
pipenv run python ./main.py pig-latin bird;
pipenv run python ./main.py cats-conundrum;
curl -X POST http://127.0.0.1:8000/api/anagrams -d '{"word": "bird"}' -H "Content-Type: application/json";
curl -X POST http://127.0.0.1:8000/api/scrabble -d '{"word": "bird"}' -H "Content-Type: application/json";
curl -X POST http://127.0.0.1:8000/api/levenshtein -d '{"word1": "bird", "word2": "taco"}' -H "Content-Type: application/json";
curl -X POST "http://127.0.0.1:8000/api/levenshtein" -d '{"word1": "bird", "word2": "taco"}' -H "Content-Type: application/json";
curl -X POST http://127.0.0.1:8000/api/rhymes -d '{"word": "bird"}' -H "Content-Type: application/json";
curl -X POST http://127.0.0.1:8000/api/piglatin -d '{"word": "bird"}' -H "Content-Type: application/json";