Skip to main content

Command line interface for the Datamuse API

Project description

datamuse-cli

A command line interface for the Datamuse API.

Installation

This tool isn't uploaded to pypi yet because the name datamuse-cli is already taken there...

pip install [TO_BE_DETERMINED]

Usage

See datamuse --help for usage information:

usage: datamuse [-h] [-n MAX_RESULTS] [-f {csv,line,json}] [-m [METADATA]]
                [-t TOPICS] [-l LEFT_CONTEXT] [-r RIGHT_CONTEXT]
                [-V {es,enwiki}] [-q QUERY_ECHO] [-d] [-v]
                mode word

Unofficial command line interface for the Datamuse API. Datamuse API
documentation: https://www.datamuse.com/api/

positional arguments:
  mode                  Type of word relationship to query:
                          ml - "Means like" (words with similar meanings)
                          sl - "Sounds like" (words with similar
                                pronunciation)
                          sp - "Spelled like" (words with similar
                                spelling)
                          rhy - Rhymes with
                          n2a - "Noun to adjective" (adjectives commonly
                                used to describe the given noun)
                          a2n - "Adjective to noun" (nouns commonly
                                modified by the given adjective)
                          syn - Synonyms
                          ant - Antonyms
                          trg - "Triggers" (words statistically
                                associated with the query word in the same
                                piece of text)
                          spc - More specific terms (hyponyms)
                          gen - More general terms (hypernyms)
                          com - "Comprises" (direct holonyms)
                          par - "Part of" (direct meronyms)
                          fol - Frequent followers
                          pre - Frequent predecessors
                          hom - Homophones (sound-alike words)
                          cns - Consonant match
                          sug - Suggestions (autocomplete)
  word                  Word or phrase to query

options:
  -h, --help            show this help message and exit
  -n, --max-results MAX_RESULTS
                        Maximum number of results to return (default: 10)
  -f, --format {csv,line,json}
                        Output format: comma-separated, line-by-line, or JSON
                        (default: csv)
  -m, --metadata [METADATA]
                        Which metadata to include in results. Options include:
                        - d (definitions)
                        - p (parts of speech)
                        - s (syllable count)
                        - r (pronunciation)
                        - f (word frequency)
                        If omitted, no metadata is included. If specified
                        without a value, all metadata is included: 'dpsrf'.
  -t, --topics TOPICS   Optional topic words. Results will be skewed toward
                        these topics. At most 5 words can be specified. Space
                        or comma delimited. Nouns work best.
  -l, --left-context LEFT_CONTEXT
                        Left context: an optional hint about the word that
                        appears immediately to the left. (Only a single word
                        may be specified.)
  -r, --right-context RIGHT_CONTEXT
                        Right context: an optional hint about the word that
                        appears immediately to the right. (Only a single word
                        may be specified.)
  -V, --vocabulary {es,enwiki}
                        Identifier for alternative vocabulary to use. By
                        default, a 550,000-term English vocabulary is used.
  -q, --query-echo QUERY_ECHO
                        Query echo: see Datamuse documentation for details.
  -d, --debug           Enable debug mode. This will print the API request to
                        the console.
  -v, --version         show program's version number and exit

(Note that compared to the Datamuse API, this tool reverses the meanings of the
"spc" and "gen" parameters.)

Examples

Words that have similar meanings to "happy":

$ datamuse ml happy
pleased, blissful, content, glad, contented, joyful, euphoric, joyous, fortunate, riant

Words that sound like "spot":

$ datamuse sl spot
spot, spott, spout, spit, spite, spat, spate, sput, spight, spet

Adjectives that are often used to modify the noun "tree", skewed toward the topic of "Carribean":

$ datamuse --topics carribean a2n tree
tropical, mango, small, entire, stately, shady, giant, famous, lemon, palm

Hyponyms (more specific terms) of "stone":

$ datamuse spc stone
calculus, cornerstone, crystal, conglomerate, capstone, gravel, marble, sill, lava, magma

Three antonyms of "day", returned in JSON format, with pronunciation and frequency metadata:

$ datamuse -n 3 -f json -m rf ant day
[
  {
    "word": "night",
    "score": 3407,
    "tags": [
      "pron:N AY1 T ",
      "f:145.767264"
    ]
  },
  {
    "word": "dark",
    "score": 2295,
    "tags": [
      "pron:D AA1 R K ",
      "f:68.871627"
    ]
  },
  {
    "word": "nighttime",
    "score": 988,
    "tags": [
      "pron:N AY1 T T AY0 M ",
      "f:1.016966"
    ]
  }
]

Future features

The Datamuse API supports queries involving a spelling filter alongside other parameters, for instance "words that have a similar meaning to 'point' and have 'o' as the third letter":

https://api.datamuse.com/words?ml=point&sp=??o*

Currently, the datamuse-cli tool does not support this feature.

Datamuse API page

https://www.datamuse.com/api/

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datamuser-0.1.1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

datamuser-0.1.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file datamuser-0.1.1.tar.gz.

File metadata

  • Download URL: datamuser-0.1.1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for datamuser-0.1.1.tar.gz
Algorithm Hash digest
SHA256 41c8dc0500b954c14b2c16ea152464f82d29992269320bd37515095cba3a052d
MD5 31e721dc918d81f17a7e8eccec45881c
BLAKE2b-256 85075d0abbb96bb7a6d450fbd763668f28b56633f5c28bdf9ff1edb264118dd7

See more details on using hashes here.

File details

Details for the file datamuser-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: datamuser-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.13.1

File hashes

Hashes for datamuser-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ea0b2a4aa95f9361ad1e8dfb8a84707cb923f746478fb996a48071a6e6372ebb
MD5 8c52229fd9254a85cf7f924820529799
BLAKE2b-256 bb65d42a77a807a636a44bf3a145b4090583c29e35f9a7eb83955d81044f06e8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page