π€
Define a Word
info.defineThe AlmanacLook-upsLooks a word up in the English Wiktionary and brings back its first meaning, what kind of word it is, an example sentence when there is one, and up to three numbered meanings ready to send.
When to use this
- β{{word.definitions}} lists up to three meanings, numbered
On the canvas
This is what Define a Word looks like when you place it on your flow. Each field below is something you configure in the inspector panel.
π€Look-ups
Define a Word
info.definewordrequired
e.g. {{input.options.word}}
asrequired
word
found
missing
error
Config fields
| Field | Type | Req | What it does |
|---|---|---|---|
worde.g. {{input.options.word}} | text | yes | Which word π€ |
asword | text | yes | Save it as β¨ |
Sparks this piece adds
After this piece runs, these values are available as sparks in every node downstream.
{{word.word}}stringThe word{{word.type}}stringnoun, verb, adjectiveβ¦{{word.definition}}stringIts first meaning{{word.example}}stringAn example sentence (when there is one){{word.definitions}}stringUp to three meanings, numbered{{word.count}}numberHow many meanings it has{{word.url}}stringLink to it on Wiktionary{{word.query}}stringWhat was looked up{{word.error}}stringWhy it couldn't be looked upOutput ports
foundThe meaning is in your spark β {{word.definition}}
missingNothing matched β {{β¦query}} says what they asked for
errorCouldn't ask right now (busy or down) β {{β¦error}} says why
π
In TypeScript, this would beβ¦
Not something you need to write β just a look at what Kitcord does for you.
TypeScript
const res = await fetch(
`https://en.wiktionary.org/api/rest_v1/page/definition/${encodeURIComponent(word)}`,
);
if (res.status === 404) return; // Missing β
const [first] = (await res.json()).en; // English meanings
const meaning = first.definitions[0].definition.replace(/<[^>]+>/g, ""); // {{word.definition}}Related pieces
More Look-ups pieces