Skip to main content

Python wrapper for the Datamuse API

Project description

[![Build Status](https://travis-ci.org/gmarmstrong/python-datamuse.svg?branch=master)](https://travis-ci.org/gmarmstrong/python-datamuse)

# python-datamuse

Python wrapper and scripts for the [Datamuse API](http://datamuse.com/api/).
Available on PyPI at <https://pypi.python.org/pypi/python-datamuse>. You can
install this library with `pip3 install python-datamuse`.

## Changelog

### Version 1.2.0

- Raise Python version to 3.6
- Mock the Datamuse API for tests
- Restructure project files
- Set README as PyPI long description

### Version 1.1.0

- Changed to Python 3
- Uploaded to PyPI, added instructions for PyPI installation
- Changed README example to reflect PyPI packaging
- Set up Travis CI
- Temporarily removed pandas
- Changed mode of scripts to executable

## Example

```python
>>> from datamuse import datamuse
>>> api = datamuse.Datamuse()
>>> orange_rhymes = api.words(rel_rhy='orange', max=5)
>>> orange_rhymes
[]
>>> orange_near_rhymes = api.words(rel_nry='orange', max=5)
>>> orange_near_rhymes
[{'score': 973, 'word': 'storage'}, {'score': 858, 'word': 'knowledge'}, {'score': 615, 'word': 'homage'}, {'score': 560, 'word': 'warrant'}]
>>>
>>>
>>> foo_complete = api.suggest(s='foo', max=10)
>>> foo_complete
[{u'score': 626, u'word': u'food'}, {u'score': 568, u'word': u'foot'}, {u'score': 520, u'word': u'fool'}, {u'score': 315, u'word': u'footage'}, {u'score': 297, u'word': u'foolish'}, {u'score': 279, u'word': u'football'}, {u'score': 272, u'word': u'footprint'}, {u'score': 232, u'word': u'footing'}, {u'score': 221, u'word': u'foof'}, {u'score': 185, u'word': u'foolproof'}]
>>> from datamuse import scripts
>>> foo_df = scripts.dm_to_df(foo_complete)
>>> foo_df
score word
0 626 food
1 568 foot
2 521 fool
3 315 footage
4 297 foolish
5 279 football
6 272 footprint
7 232 footing
8 221 foof
9 185 foolproof

[10 rows x 2 columns]
```

Note that the default number of results is set to 100. You can set the default
`max` to something else using the `set_max_default` method, e.g.
`api.set_max_default(300)`. Datamuse only returns 1000 results max.


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

python-datamuse-1.2.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

python_datamuse-1.2.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file python-datamuse-1.2.0.tar.gz.

File metadata

  • Download URL: python-datamuse-1.2.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.6

File hashes

Hashes for python-datamuse-1.2.0.tar.gz
Algorithm Hash digest
SHA256 d5ec8ade20b2c1ef38a54969ab8c245acc11c17335798b99aca2dc3a36c12505
MD5 9ff90cb39d3a5746eda312c1dd1c3215
BLAKE2b-256 d8a4ac04ad97de9f29cb8c88c4fdf8a8d42689241d53cc6ad1390d748edebfa8

See more details on using hashes here.

File details

Details for the file python_datamuse-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: python_datamuse-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 3.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.6

File hashes

Hashes for python_datamuse-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c6b4488d9efeedcb716f66b84b0b36af728960be14bfb7bf4121fef484a7f57e
MD5 13e3f06fed09884fe02ceb7e3e2f8c0d
BLAKE2b-256 b70717e42f9ce16ff527084746787ecf44d5fe6b575736ff64d2d28f7f5e1c74

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