Reverse Polish Abbreviations Generator

[The below provides a good example of pseudo code thinking about how to re-structure and progressively evolve / improve your program]

So in my previous post about "Something (Not) Happening" (here), I hinted at my reversal of strategy. I'm now switching to the use of "post-fix" operators instead of using "pre-fix" ones. This was for a project that I called my abbreviations-expanding Python program (an OOP project) but now I'm generalizing it to be an "Xpander" class for more than just abbreviations. (The latter explained below and also in my next post.)

So I was initially thinking like a programmer and assuming that the abbreviation expansion trigger (e.g., the prime char [`]  on the keyboard) should be hit first (in so-called "pre-fix" style) in order to invoke an abbreviation expansion operation. However, I should have been thinking like a user of the software not like a programmer focusing on delimiters. Please see the keyboard image below.



From the user's perspective, the process would go like this:

You are typing some prose in left to right progression, say: "The quick brown fox jum...". As you hit the "j" key, you recall that you have a prestored abbreviation for the word, "jumped". You recall the name of that shortcut as being "j prime". So you type the j and then hit the prime key on your keyboard (that's the one that has a left tilted quote mark. It's located just below the ESCAPE key on the top left of your keyboard). After hitting the prime key (`), you usually hit the space key OR the enter key, and sometimes,  a sentence terminator like period (.), question mark (?), colon (:), etc.  Medium link for above image is (here)

In response, the software detects presence of the lone prime character (`) and presence of the subsequent space/line-terminator. The program looks back to the lone prime (`) --where here, the term "lone"  means there are no further primes or other triggers in continuous sequence with that detected prime. Then it looks to the one preceding character (in this case, a lower case "j") before the lone prime. 

The program then uses the latter as a lookup key into your currently-specified Python dictionary, fetches the corresponding substitution text (e.g., "jumped " --note the space included at the end of this example), replaces the "j prime" that you just typed with the longer  substitute text. 

The substitute text can be much longer than just one word (e.g., "jumped"). It could have been a long URL, or a file path name, or a file path name plus a file name. The point is that a short bitly-like sequence is converted into a long form as specified by the applicable lookup table (LUT). Then the software lets you keep typing some more text. 

The single abbreviation char followed by prime and space is the simplest case.  Exceptions or "edge" cases occur for example where there was a space or a sentence terminator after the lone prime (`), say a period (.), in which case the software should delete the last space in the substitute text, if present, so you don't inadvertently end up with two spaces or a space before the sentence terminator. -- [To Be Continued?]

The above case of the  lone-lookup key followed by the lone post-fix prime (e.g., j `is just one example! The user could have instead typed a double prime after the one char abv specifier (e.g., j ` ` ). In this case, the software converts the double prime into an index for picking a second abbreviation substitution from within a list of abbreviation substitutions associated with the lone "j" key. Alternatively, if the user typed an unbroken sequence of triple primes (j ` ` `), the software picks the third item in the list. Currently I'm thinking of a maximum of four primes ( ` ` ` ` ), meaning only 4 abbreviations in the selection list for the lower case j key.  {In the future there may be a special mixed-triggers sequence (a.k.a. here as mixed P3 P4 sequence) where you can have a list with up to 12 substitutes -- using the 1-9 keys plus the 0. -, = keys.}

Note however, that we can also have used a capital "J" as a lookup key with its own list of selectable substitutes. So that gives us as many as 8 selectable abbreviations for the concept of "J" as an abbreviation. More specifically, the following two-entry dictionary (to be used in the context where the user is operating as a lawyer) might be: { 'j' : ["jumped ", "justice", "jury", "justification"], 'J' : ["jurisdiction", "jumping to a conclusion", "justifiable homicide", "judge, jury and executioner"]. (It will take some amount of thought to come up with a more useful set of J-related expansions for different users operating in different roles / contexts. More on the latter issue is discussed below.)

In my implementation, a second postfix trigger on the keyboard is the Tilda (~) character (a.k.a. P4). This is typed as an up-shifted prime key. The user is to become habituated to using that top left button ( ` or ~ ) for triggering various Xpander effects (latter is name of my class object). In my implementation, the Tilda (~) postfix (a.k.a. P4allows for dictionary lookup keys preceding it that are longer than a lone one character (e.g., the above "j" and "J" examples). The multi-character abbreviation key cannot include spaces and additionally, it must be preceded by a space or a line return or be the first character (slice index =0) in the input text. One example of this may occur with the user typing:

     "I plan to qabg~ dfx~ a class in py~."

Here, the [space]qabg~ sequence generates the looked-up substitute output of "Query in Google about" ("QAB" stands for Query ABout in my bookmarks; "QIF" stands for Query IF).   The [space] dfx~ sequence generates the looked-up substitute output of "defining" (the ending x signifies an "ing" ending in my abv dictionaries, where just "df~" might substitute for "define" and "dfy~" might substitute for "definitely"The subsequent [space] py~ sequence generates the looked-up output of "Python ". So the initial input text gets converted into: 

    "I plan to Query in Google about defining a class in Python."

[The above example of the "qabg" abbreviation is to be part of a set of "Query ABout" lookups that further include qaby =  "Query in YouTube about", qabr =  "Query in Reddit about", qabw =  "Query in Wikipedia about" ... and further more, a "c" specifier might be used for ChatGTP, while "p" is used for Perplexity, and so on.] 

In the future, I plan to allow for "mixed" post-fix triggers, say a prime (`) immediately followed by a Tilda (~) rather than only allowing for mono-trigger-character sequences, meaning just all primes ( ` ` ` ` ) or just all Tildas ( ~ ~ ~ ~ ). I haven't made up my mind yet, but I'm thinking of such mixed trigger sequences as causing a launching of respective macro routines !!!  (e.g. written in Py, or AHK or VBA or JS). Or perhaps causing opening of respective web pages (e.g., specific ones of my Old Man ___ posts, where the fill-in blank can be: Learns To Code, Learns about Learning, Talks Politics, etc.). The possibilities for the  "mixed" post-fix triggers is endless !! (See my next post which goes into more detail about planning for a [P4] [P3]  sequence.)

Meta-cognition: Note how the above discussion evolved into the emergence of ideas beyond just using the Xpander class for abbreviations!! We are now talking about expanding short sequences of text into actions (a.k.a. macros / script executions) other than just longer-form substitute texts !!!

QABg ::: Causing a Python program to launch a macro or external script

What about the abbreviations themselves? They don't have to be single or plural words. They could be URL's linking to web content or Shortcuts linking to local files. They could be QAB's -- To Be Continued

I'm not quite all there yet with my current Py project. Right now I drafted a
"(dot).help" method that explains how the algorithm is to work and a "(dot).menu" method that displays one of the test dictionaries in its entirety (New idea: What about shorter menus for showing the substitutes of just one letter of the alph
abet at a time?). Also I made a dictionary generating method that populates the dictionary with all possible one char keys such as a-z, A-Z, etc. Some special case modifications have to be made, like for the back-slash escape key -- To Be Continued

MORE TO EXPLORE
QABg ::: Context dependent abbreviations
    --^^^-- Example of Context Sensitive Abbreviations
    --^^^-- Context-Aware Abbreviation Expansion Using Large Language Models
    --^^^-- Automatic expansion of abbreviations by using context and character information
    --^^^-- GitHub -- Computer code related abbreviations
    --^^^-- Oxford Dictionary List of Abbrev's    [Broader OED entries HERE] [Grammar

QABy ::: Context Dependent Abbreviations   -- Abbreviations & Acronyms to Build Your Vocabulary
    --^^^-- Interactive English [playlists here]
    --^^^-- [ASAP =] Useful Business Expressions to Sound More Professional
    --^^^-- Internet Abbreviations & Acronyms YOU SHOULD KNOW in 2021  [more here]
    --^^^-- 100 Must-Know Acronyms & Abbreviations You Use Every Day

QABw ::: Context dependent abbreviations [Wikipedia]


Here are some picked off abbreviations from my previous VBA-based software where I operated in the role / context of being a patent attorney --the first one being my "standard" dependent claim argument:

~std~ Claim/s 6 depend/s from claim 1.  Therefore, claim 6 is distinguishable from X1 and X2 for the same reasons as claim 1. Applicant further asserts that X3 does not remedy the deficiencies of X1 and X2~~
~aha~ (as here amended)~~
~sel~ selectively~~
~//~ and/or ~~  [note: we can't use a single back slash in Python because it's reserved as an escape character]
~inx~ indicating ~~
~asg~ assigned ~~
~dyo~ directly or indirectly~~
~prr~ presented presentation~~
~acc~ according to~~
~pvx~ providing ~~
~ix~ including ~~
~pra~ present application ~~
~prd~ present disclosure of~~
~g1~ configuration ~~
~hhh~ he/she ~~
~dfx~ defining ~~
~dody~ directly or indirectly~~
~si~ simultaneously ~~
~aka~ (a.k.a. ~~ (also known as)~~
~nec~ necessarily~~
~io~ user-information input~~
~ req~ required requested~~
~rprd~ represented by~~
~bec~ become ~~
~con~ continue continued continuation~~
~ia~ interaction ~~
~temp~ temporarily ~~
~ap~ appreciate appreciated appreciation ~~
~ms~ more specifically,  ~~
~op~ optionally~~
~how~ however, ~~
~dr~ directly ~~ directed to~~
~yms~ Yet more specifically, ~~
~tg~ together ~~
~gen~ generate ~~
~tw~ therewith ~~
~eq~ equivalent ~~
~avv~ available availability ~~ 
~bot~ bottom ~~
~in~ indicated indicating indication indicative_of ~~
~lut~ lookup table (LUT)~~
~idy~ identity identified identifying ~~
~dii~ difference~~
~att~ attribute~~
~mbp~ may be provided ~~
~ s~ specification~~ said ~~
~R~ received~~ recognized ~~ recipients ~~ 
~ v~ wherein ~~ against ~~
~ V~ against ~~ wherein ~~

2X*X*X*X*X*X*X*X*

~pd~ predetermined~~ present disclosure~~
~oc~ of course,~~
~icw~ in conjunction with~~
~oto~ On the other hand,~~
~fu~ further ~~
~ott~ another ~~
~ot~ other ~~
~oott~ one another~~
~oton~ one to the next~~
~bl~ backlighting ~~
~mu~ multi-user ~~microstructure ~~
~ D~ direction ~~ Office action ~~
~spa~ spaced apart ~~
~spar~ spaced apart relationship~~
~pv~ provided~~
~te~ teachings~~
~pte~ the present teachings~~
~xp~ transparent ~~
~do~ disclosure of ~~
~pdo~ present disclosure of~~
~pcv~ perceived ~~
~ex~ extending~~
~adj~ adjacent ~~

~wrt~ With regard to ~~
~wrtc~ With regard to Claim~~
~oa~ Office action ~~
~sp~ specific ied~~ subpixel ~~
~dd~ disposed ~~
~iy~ integrally ~~

~eh~ each ~~
~ehot~ each other~~
~eho~ each of the other~~
~ual~ upper and lower ~~

~th~ thereby~~
~di~ different ~~
~be~ being ~~
~tf~ that of ~~
~ivd~ interposed ~~
~df~ defined~~
~irs~ it is respectfully submitted~~
xxxxxx

Comments

Popular posts from this blog

Links for Python Noobs

The Learn HOW to Learn Page

Advanced Python Links Accumulation Page