aXXb: A python tool to decode and disambiguate numeronyms
In recent years I started encountering numeronyms at work, such as a11y — which stands for accessibility — or i18n for internationalization. These work by taking the first letter, the last letter, and inserting in between the number of letters in the word.
The challenge is that numeronyms are insider shorthand — either you know them, or you don’t. I certainly can’t list all the 13-letter words starting with a and ending with y from memory. That’s where a computer (and a dictionary) comes in handy.
First Python implementation
Linux has access to a dictionary of words at /usr/share/dict/words
.
~$ head /usr/share/dict/words
A
AA
AAA
AA's
AB
ABC
ABC's
ABCs
ABM
ABM's
The first words may not be very interesting, but we get the idea. We can count how many words are in the dictionary:
~$ wc -l /usr/share/dict/words
104334 /usr/share/dict/words
104 thousand words… this is the haystack where I need to find the needle.
Here’s a simple brute-force approach:
import sys
dictionary = []
with open("/usr/share/dict/words") as words:
for word in words:
dictionary.append(word.lower().strip())
def matches(word: str, numeronym: str) -> bool:
return (word[0] == numeronym[0] and
word[-1] == numeronym[-1]
and len(word) == int(numeronym[1:-1]) + 2)
if __name__ == "__main__":
numeronym = sys.argv[1]
if len(numeronym) <= 2:
print(numeronym)
exit(0)
print([word for word in dictionary if matches(word, numeronym)])
Running it gives:
~$ python3 axxb.py a11y
['acceptability', 'accessibility', 'admissibility', 'adventurously', 'aesthetically', 'affirmatively', 'algebraically', 'allegorically', 'alternatively', 'apathetically', 'applicability', 'appropriately', 'approximately', 'artificiality', 'astonishingly', 'attributively', 'authentically', 'autobiography', 'automatically', 'axiomatically']
Despite brute-forcing the entire word list, the script runs nearly instantly — the simplest approach is good enough.
Another approach would be to store the candidates in a dictionary keyed by a tuple (first_letter, length, last_letter)
, which would give O(1) lookup. For these decisions, I favor readability over pure performance.
aXXb as a service
While the script works, it requires me to be at my computer and run Python. What if this was available as a service?
The key realization is that there are only around 5000 possible numeronyms in english — far fewer than the 100,000 words in the dictionary — because the same numeronysm can represent many words. Rather than recalculating every time, why not pre-generate files for all possible numeronyms?
I serve these using GitHub Pages. It serves a static website from a Git repository, which is perfect for me. I simply placed all the files that my generator script created into the repo.
You can try it out at axxb.samuelpapin.com/a11y — just replace a11y
in the URL with any numeronym to see its matches.
Parting thoughts
I didn’t build this tool to show off technical skill, but because numeronyms often split the audience: those who know the meaning, and those left behind. It can feel like gatekeeping. As a non-native English speaker, I notice this even more. This tool is my small reminder that what’s obvious to some isn’t always obvious to others.