Good words for “before” and “after” that sort the same, both logically and alphabetically?

TL;DR – Silly OCD question looking for better words.

I have a list of event labels in a computer program similar to:

  • renderer_before
  • renderer_after
  • before_notify
  • after_notify

This is all well and good…those names convey the context of each event succinctly and accurately.

BUT! It bugs me that "before" comes after "after" when sorted alphabetically. Same for "pre" and "post".

What is a good pair of words that indicates a relative sequence between two things, that just happens to alphabetically sort in the same order?

Answer

Saw this post in https://stackoverflow.com/questions/66144666/words-for-pre-post-or-before-after-that-sort-the-same-logically-and-alph and I thought it was criminal that the question was closed.

I wrote a script to help find candidate pairs that satisfy the (entirely objective, and IMO subjectively righteous) criteria.

def the_important_questions_in_life():
    """
    https://www.guru99.com/wordnet-nltk.html
    https://english.stackexchange.com/questions/560104/good-words-for-before-and-after-that-sort-the-same-both-logically-and-alpha?newreg=acc68d7cb6aa400abed569edbdb4bfab
    https://stackoverflow.com/questions/66144666/words-for-pre-post-or-before-after-that-sort-the-same-logically-and-alph
    """

    import nltk
    nltk.download('wordnet')
    from nltk.corpus import wordnet

    before_queries = [
        'before', 'pre', 'anterior', 'prior', 'first', 'start', 'past',
        'earlier', 'predecessor', 'current', 'former',
    ]
    after_queries = [
        'after', 'subsequent', 'later', 'next', 'finish', 'successor',
        'posterior', 'future',
    ]

    synonyms = []
    antonyms = []

    for query in before_queries:
        syns = wordnet.synsets(query)
        for syn in syns:
            lems = syn.lemmas()
            for lem in lems:
                synonyms.append(lem.name())
                if lem.antonyms():
                    antonyms.append(lem.antonyms()[0].name())

    for query in after_queries:
        syns = wordnet.synsets(query)
        for syn in syns:
            lems = syn.lemmas()
            for lem in lems:
                antonyms.append(lem.name())
                if lem.antonyms():
                    synonyms.append(lem.antonyms()[0].name())

    print('synonyms = {!r}'.format(sorted(set(synonyms))))
    print('antonyms = {!r}'.format(sorted(set(antonyms))))

I wasn’t able to get the synonym finder to work exactly like I wanted, so I didn’t finish the script, but assuming you have an API that can find good synonyms and antonyms for words, it should be simple enough to find pairs of them that sort alphabetically.

From this programmatic search, I settled on these manually found sets of pairs:

  • earlier later
  • head tail
  • anterior posterior
  • first last
  • predecessor successor
  • current next
  • previous subsequent
  • before hereafter
  • preceding succeeding

Attribution
Source : Link , Question Author : David Hempy , Answer Author : Erotemic

Leave a Comment