This Gist was automatically created by Carbide, a free online programming environment.
Created
May 3, 2026 05:00
-
-
Save carbide-public/7559696f1d61dd11235e1283aaf47ea3 to your computer and use it in GitHub Desktop.
untitled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let word = "gehen" | |
| let endpoint = 'https://en.wiktionary.org/api/rest_v1/page/definition' | |
| let filter = new RegExp('< *\\/? *[a-z]+ *( [a-z]+="[^<>"]+" *)* *\\/? *>', 'ig') | |
| let url = `${endpoint}/${word}` | |
| let resObj = await fetch(url, {orgin:'test'}) | |
| let res = await resObj.json() | |
| function cleanString(str) { | |
| return str.replaceAll(filter, '').replaceAll(' ', ' ') | |
| } | |
| let output = '' | |
| for (let meaning of res.en) { | |
| output += meaning.partOfSpeech | |
| for (let definition of meaning.definitions) { | |
| if (definition.definition) { | |
| let filteredDefinition = cleanString(definition.definition) | |
| output += `\n- ${filteredDefinition}` | |
| if (definition.examples) { | |
| for (let example of definition.examples) { | |
| let filteredExample = cleanString(example) | |
| output += `\n "${filteredExample}"` | |
| } | |
| } | |
| } | |
| } | |
| output += '\n\n' | |
| } | |
| output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment