Skip to content

Instantly share code, notes, and snippets.

@mcnemesis
Last active April 1, 2026 06:02
Show Gist options
  • Select an option

  • Save mcnemesis/e35820d78f71984d53ccb986c621665e to your computer and use it in GitHub Desktop.

Select an option

Save mcnemesis/e35820d78f71984d53ccb986c621665e to your computer and use it in GitHub Desktop.
FREE DICTIONARY | LEXICON is a TEA program for looking-up and presenting definitions, and with the capability of compiling a list of definitions for export or easy sharing. This version addresses an [external attack?] glitch noticed when using TEA on the command-line.
#!/usr/bin/tttt -fc
v:vABOUT:{
*****************************
FREE LEXICON v3
*****************************
Use this app to simply look-up terms or build a list of definitions.
It is based on Dictionary API that mostly focuses on standard terms, thus, some queries might have no resolutions. Feel free to proceed...}
# Windows/Microsoft could be under-attack (noticed while testing this app)
# thus this [hack-proof] version that forces all interact commands to use
# i: and not i*: so that for command-line TEA, we need not use any GUI
# (thus no Py/Tk widgets)
# otherwise, original version of TEA LEXICON v1 is at:
# https://gist.github.com/mcnemesis/6bb975c3051bd0b9ebece8c5a73ce336
---[ CONSTANTS ]
v:vFOOTER:{PROCESSED VIA FREE LEXICON @ tea.nuchwezi.com}
v:vDELIM:*****************************
v:vQUERY_PROMPT:{Enter Word or Phrase to Look-Up:}
v:vNL:{
}
v:vPREFIX_QUERY:{QUERY: }
v:vPREFIX_DEFINITIONS:{
DEFINITION(s):
}
v:vMENU_NEXT:{PICK next ACTION >
1: Return last definition + Quit
2: Return all definitions + Quit
3: Process Next Query (default)}
# shall want to know where program is being run from
z.:PLATFORM | v:vENVIRONMENT
---[ VARIABLES ]
v:vQUERY:{} # what to define
v:vLIST_RESULTS:{}
---[ INTRO ]
y:vABOUT | i:
---[ MENU ]
l:lQUERY_PROMPT
y:vQUERY_PROMPT | i: | t.!: | v:vQUERY
---[ PROCESS ]
y:vQUERY | f:^$:lQUERY_PROMPT
x*:vPREFIX_QUERY:vQUERY
v:vPRESENT_QUERY
# dictionary api requires call of format:
# https://api.dictionaryapi.dev/api/v2/entries/en/<term>
v:vURL:https://api.dictionaryapi.dev/api/v2/entries/en/
x*:vURL:vQUERY | v:vURL # update url
# we shall want to pretend we are curl if in CLI-TEA
y:vENVIRONMENT | f!:CLI:lNCLI
v:User-Agent:curl/7.68.0
w*.:User-Agent
l:lNCLI
# then make call..
w*:vURL
v:vAPI_RESULTS # store result from API
h!:,
k:definition
h!::
k!:{"definitions"|"definition"}
r!:{:"}:{->}
r!:{."}:{.}
v:vDEFINITIONS
v:vPREFIX_DEFINITIONS:{
DEFINITION(s):
}
x*:vPREFIX_DEFINITIONS:vDEFINITIONS
v:vPRESENT_DEFINITION
---[ PRESENT ]
g*!:vNL:vDELIM:vPRESENT_QUERY:vPRESENT_DEFINITION
v:vANSWER
i: # present current definition...
g*!:vNL:vLIST_RESULTS:vANSWER | v:vLIST_RESULTS # store defn
---[ FINISH ]
g*!:vNL:vNL:vDELIM:vFOOTER | v:vUSE_FOOTER
y:vMENU_NEXT | i: | t.!: | v:vOPT
f!:^[123]$:lQUERY_PROMPT
f!:1:lNPROC1
y:vANSWER | x*!:vUSE_FOOTER | q!:
l:lNPROC1
f!:2:lNPROC2
y:vLIST_RESULTS | x*!:vUSE_FOOTER | q!:
l:lNPROC2
j:lQUERY_PROMPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment