diff --git a/README.md b/README.md index 39c7b60..f2eb42c 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,7 @@ Run `opencli list` for the live registry. | **bloomberg** | `main` `markets` `economics` `industries` `tech` `politics` `businessweek` `opinions` `feeds` `news` | Public / Browser | | **ctrip** | `search` | Browser | | **devto** | `top` `tag` `user` | Public | +| **dictionary** | `search` `synonyms` `examples` | Public | | **arxiv** | `search` `paper` | Public | | **wikipedia** | `search` `summary` | Public | | **hackernews** | `top` | Public | diff --git a/README.zh-CN.md b/README.zh-CN.md index 7fb4f73..dff1914 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -143,6 +143,7 @@ npm install -g @jackwener/opencli@latest | **bloomberg** | `main` `markets` `economics` `industries` `tech` `politics` `businessweek` `opinions` `feeds` `news` | 公共 API / 浏览器 | | **ctrip** | `search` | 浏览器 | | **devto** | `top` `tag` `user` | 公开 | +| **dictionary** | `search` `synonyms` `examples` | 公开 | | **arxiv** | `search` `paper` | 公开 | | **wikipedia** | `search` `summary` | 公开 | | **hackernews** | `top` | 公共 API | diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index f90e76c..e446920 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -79,6 +79,7 @@ export default defineConfig({ items: [ { text: 'HackerNews', link: '/adapters/browser/hackernews' }, { text: 'Dev.to', link: '/adapters/browser/devto' }, + { text: 'Dictionary', link: '/adapters/browser/dictionary' }, { text: 'BBC', link: '/adapters/browser/bbc' }, { text: 'Apple Podcasts', link: '/adapters/browser/apple-podcasts' }, { text: 'Xiaoyuzhou', link: '/adapters/browser/xiaoyuzhou' }, diff --git a/docs/adapters/browser/dictionary.md b/docs/adapters/browser/dictionary.md new file mode 100644 index 0000000..6e660b2 --- /dev/null +++ b/docs/adapters/browser/dictionary.md @@ -0,0 +1,27 @@ +# Dictionary + +**Mode**: 🌐 Public · **Domain**: `api.dictionaryapi.dev` + +Search the open dictionary to quickly fetch native definitions, part of speech contexts, and phonetic pronunciations directly in your IDE terminal. + +## Commands + +| Command | Description | +|---------|-------------| +| `opencli dictionary search` | Fetch the exact definition of a word | +| `opencli dictionary synonyms` | Find related synonyms for a word | +| `opencli dictionary examples` | Read real-world sentence usage examples | + +## Usage Examples + +```bash +# Look up a complex term +opencli dictionary search --word "serendipity" + +# Discover phonetics +opencli dictionary search --word "ephemeral" +``` + +## Prerequisites + +- No browser required — utilizes the fast, open JSON definitions API. diff --git a/docs/adapters/index.md b/docs/adapters/index.md index 247ca5d..bd6ea50 100644 --- a/docs/adapters/index.md +++ b/docs/adapters/index.md @@ -36,6 +36,7 @@ Run `opencli list` for the live registry. | **[hackernews](/adapters/browser/hackernews)** | `top` | 🌐 Public | | **[bbc](/adapters/browser/bbc)** | `news` | 🌐 Public | | **[devto](/adapters/browser/devto)** | `top` `tag` `user` | 🌐 Public | +| **[dictionary](/adapters/browser/dictionary)** | `search` `synonyms` `examples` | 🌐 Public | | **[apple-podcasts](/adapters/browser/apple-podcasts)** | `search` `episodes` `top` | 🌐 Public | | **[xiaoyuzhou](/adapters/browser/xiaoyuzhou)** | `podcast` `podcast-episodes` `episode` | 🌐 Public | | **[yahoo-finance](/adapters/browser/yahoo-finance)** | `quote` | 🌐 Public | diff --git a/src/clis/dictionary/examples.yaml b/src/clis/dictionary/examples.yaml new file mode 100644 index 0000000..9972c53 --- /dev/null +++ b/src/clis/dictionary/examples.yaml @@ -0,0 +1,24 @@ +site: dictionary +name: examples +description: Read real-world example sentences utilizing the word +domain: api.dictionaryapi.dev +strategy: public +browser: false + +args: + word: + type: string + required: true + description: Word to get example sentences for + +pipeline: + - fetch: + url: "https://api.dictionaryapi.dev/api/v2/entries/en/${{ args.word }}" + + - map: + word: "${{ item.word }}" + example: "${{ (() => { if (item.meanings) { for (const m of item.meanings) { if (m.definitions) { for (const d of m.definitions) { if (d.example) return d.example; } } } } return 'No example found in API.'; })() }}" + + - limit: 1 + +columns: [word, example] diff --git a/src/clis/dictionary/search.yaml b/src/clis/dictionary/search.yaml new file mode 100644 index 0000000..ce9a860 --- /dev/null +++ b/src/clis/dictionary/search.yaml @@ -0,0 +1,26 @@ +site: dictionary +name: search +description: Search the Free Dictionary API for definitions, parts of speech, and pronunciations. +domain: api.dictionaryapi.dev +strategy: public +browser: false + +args: + word: + type: string + required: true + description: Word to define (e.g., serendipity) + +pipeline: + - fetch: + url: "https://api.dictionaryapi.dev/api/v2/entries/en/${{ args.word }}" + + - map: + word: "${{ item.word }}" + phonetic: "${{ item.phonetic || item.phonetics?.[0]?.text || item.phonetics?.[1]?.text || '' }}" + type: "${{ item.meanings[0].partOfSpeech }}" + definition: "${{ item.meanings[0].definitions[0].definition }}" + + - limit: 1 + +columns: [word, phonetic, type, definition] diff --git a/src/clis/dictionary/synonyms.yaml b/src/clis/dictionary/synonyms.yaml new file mode 100644 index 0000000..05d3794 --- /dev/null +++ b/src/clis/dictionary/synonyms.yaml @@ -0,0 +1,24 @@ +site: dictionary +name: synonyms +description: Find synonyms for a specific word +domain: api.dictionaryapi.dev +strategy: public +browser: false + +args: + word: + type: string + required: true + description: Word to find synonyms for (e.g., serendipity) + +pipeline: + - fetch: + url: "https://api.dictionaryapi.dev/api/v2/entries/en/${{ args.word }}" + + - map: + word: "${{ item.word }}" + synonyms: "${{ (() => { const s = new Set(); if (item.meanings) { for (const m of item.meanings) { if (m.synonyms) { for (const syn of m.synonyms) s.add(syn); } if (m.definitions) { for (const d of m.definitions) { if (d.synonyms) { for (const syn of d.synonyms) s.add(syn); } } } } } const arr = Array.from(s); return arr.length > 0 ? arr.slice(0, 5).join(', ') : 'No synonyms found in API.'; })() }}" + + - limit: 1 + +columns: [word, synonyms]