Vocabulary
Golang package to get meanings, synonyms, antonyms and more for a word
Install / Use
/learn @karan/VocabularyREADME
Vocabulary
An English-language dictionary and thesaurus in a Go package by Karan Goel.
Golang port of the Python counterpart.
For a given word, Vocabulary will give you:
- Meaning
- Synonyms
- Antonyms
- Part of speech: whether the word is a noun, interjection or an adverb et el
- Usage example: a quick example on how to use the word in a sentence
Features
- Written in idiomatic Go
- No external dependencies
- So easy, a five-year-old can use it
- Works on Mac, Linux and Windows.
Installation
$ go get -u github.com/karan/vocabulary
Usage
Get API keys
- Required for
Antonyms
- Required for
PartOfSpeech
Calling vocabulary.Word() with any word as a string will return a vocabulary.Word type object that has all possible information about it.
Or if you just want selective information, you can call individual functions passing in a word (vocabulary.Meanings("hallucination")).
package main
// Simple example usage of
// github.com/karan/vocabulary
import (
"fmt"
"log"
"github.com/karan/vocabulary"
)
func main() {
// Set the API keys
// Some functions require API keys. Refer to docs.
// If API keys are not required, simple set empty strings as config:
c := &vocabulary.Config{BigHugeLabsApiKey: BigHugeLabsApiKey, WordnikApiKey: WordnikApiKey}
// Instantiate a Vocabulary object with your config
v, err := vocabulary.New(c)
if err != nil {
log.Fatal(err)
}
// Create a new vocabulary.Word object, and collects all possible information.
word, err := v.Word("vuvuzela")
if err != nil {
log.Fatal(err)
}
fmt.Printf("word.Word = %s \n", word.Word)
fmt.Printf("word.Meanings = %s \n", word.Meanings)
fmt.Printf("word.Synonyms = %s \n", word.Synonyms)
fmt.Printf("word.Antonyms = %s \n", word.Antonyms)
fmt.Printf("word.PartOfSpeech = %s \n", word.PartOfSpeech)
fmt.Printf("word.UsageExample = %s \n", word.UsageExample)
// Get just the synonyms
// synonyms, err := v.Synonyms("area")
// if err != nil {
// log.Fatal(err)
// }
// for _, s := range synonyms {
// fmt.Println(s)
// }
//
// Get just the antonyms
// ants, err := v.Antonyms("love")
// if err != nil {
// log.Fatal(err)
// }
// for _, a := range ants {
// fmt.Println(a)
// }
// Get just the part of speech
// pos, err := v.PartOfSpeech("love")
// if err != nil {
// log.Fatal(err)
// }
// for _, a := range pos {
// fmt.Println(a)
// }
// Can also use:
// v.UsageExample(word)
}
Tests
Create examples/api_keys.go with your API keys:
package main
const (
BigHugeLabsApiKey = "xxxx"
WordnikApiKey = "xxxx"
)
Then, to run the tests, use this command:
$ go test
PASS
Bugs
Please use the issue tracker to submit any bugs or feature requests.
License
MIT License © Karan Goel
Related Skills
node-connect
343.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
92.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。


