Skip to main content

Wordbook is a Python asynchronous library to query Dict servers. It implements the main parts of DICT protocol (RFC 2229<https://tools.ietf.org/html/rfc2229>).

The library consists two classes:

  • DictBase: which implements commands from RFC2229.

  • Wordbook: which exposes more abstract methods to find a definition within dictionaries.

Both classes are asynchronous and require Python 3.5+.

Installation

To install from pypi

$ sudo pip install wordbook

or from source:

$ sudo python setup.py install

Examples

Getting information from a server using the DictBase class:

import asyncio
import wordbook


async def main():
    dictb = wordbook.DictBase()
    await dictb.connect()
    await dictb.client('wordbook/server-status.py')
    info = await dictb.show_server()
    for line in info:
        print(line)


if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())
    loop.close()

Output:

dictd 1.12.1/rf on Linux 4.10.0-30-generic
On LT19758: up 07:55:45, 5 forks (0.6/hour)

Database      Headwords         Index          Data  Uncompressed
gcide              203645       3859 kB         12 MB         38 MB
wn                 147311       3002 kB       9247 kB         29 MB
moby-thesaurus      30263        528 kB         10 MB         28 MB

Getting definition of word mock using the WordBookDatabase class:

import asyncio
import wordbook

async def main():
    wb = wordbook.WordBookDatabase('wn')
    await wb.connect()
    lines = await wb.define('mock')
    for line in lines:
        print(line)

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())
    loop.close()

Output:

["mock" wn "WordNet (r) 3.0 (2006)"]
mock
    adj 1: constituting a copy or imitation of something; "boys in
           mock battle"
    n 1: the act of mocking or ridiculing; "they made a mock of him"
    v 1: treat with contempt; "The new constitution mocks all
         democratic principles" [syn: {mock}, {bemock}]
    2: imitate with mockery and derision; "The children mocked their
       handicapped classmate"

You can find more examples in directory example/.

Resources

Metadata

Release files for wordbook 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wordbook 1.0.0
File Size Uploaded Provenance Actions
wordbook-1.0.0.tar.gz 4.8 kB Without provenance Details for wordbook-1.0.0.tar.gz

Release files / wordbook-1.0.0.tar.gz

Download URL wordbook-1.0.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
384e866a7b8d29629912773fccce728228f28707a4ab6602112255e50e9048f5
BLAKE2b-256 checksum
How to use checksums
6dc1326a9f3ed69c4cf2250641fc07c5c9a205ed00af36f715152d16d57e7823
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for wordbook 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page