Skip to main content

Module to get meaning, synonym, antonym, part_of_speech, usage_example, pronunciation and hyphenation for a given word

Project description

Vocabulary

PyPI version License Python Versions Build Status

A dictionary magician in the form of a module!

Table of Contents

What is it

Using Vocabulary, you can get

  • 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

  • Pronuciation

  • Hyphenation : Breaks down the word and shows the particular stress points(if any) during pronunciation

for a given word!

Features

Installation

Option 1: installing through pip (Suggested way)

pypi package link

$ pip install vocabulary

If you are behind a proxy

$ pip --proxy [username:password@]domain_name:port install vocabulary

Note: If you get command not found then $ sudo apt-get install python-pip should fix that

Option 2: Installing from source

$ git clone https://github.com/prodicus/vocabulary.git
$ cd vocabulary/
$ pip install -r requirements.txt
$ python setup.py install

Uninstalling

$ pip uninstall vocabulary

Demo

Demo link

Demo link

Usage

A Simple demonstration of the module

## Importing the module
>>> from vocabulary import Vocabulary as vb

## Extracting "Meaning"
>>> vb.meaning("hillbilly")
[{'text': 'Someone who is from the hills; especially from a rural area, with a connotation of a lack of refinement or sophistication.', 'seq': 0}, {'text': 'someone who is from the hills', 'seq': 1}, {'text': 'A white person from the rural southern part of the United States.', 'seq': 2}]
>>>

## "Synonym"
>>> vb.synonym("hurricane")
'[{"text": "storm", "seq": 0}, {"text": "tropical cyclone", "seq": 1}, {"text": "typhoon", "seq": 2}, {"text": "gale", "seq": 3}]'
>>>

## "Antonym"
>>> vb.antonym("respect")
'{"text": ["disesteem", "disrespect"]}'
>>> vb.antonym("insane")
'{"text": ["sane"]}'

## "Part of Speech"
>>> vb.part_of_speech("hello")
[{'text': 'interjection', 'example:': 'Used to greet someone, answer the telephone, or express surprise.', 'seq': 0}]
>>>

## "Usage Examples"
>>> vb.usage_example("chicanery")
'[{"text": "The Bush Administration is now the commander-in-theif (lower-case intentional) thanks to their chicanery.", "seq": 0}]'
>>>

## "Pronunciation"
>>> vb.pronunciation("hippopotamus")
[{'raw': '(hĭpˌə-pŏtˈə-məs)', 'rawType': 'ahd-legacy', 'seq': 0}, {'raw': 'HH IH2 P AH0 P AA1 T AH0 M AH0 S', 'rawType': 'arpabet', 'seq': 0}]
>>>

## "Hyphenation"
>>> vb.hyphenation("hippopotamus")
[{'text': 'hip', 'type': 'secondary stress', 'seq': 0}, {'text': 'po', 'seq': 1}, {'text': 'pot', 'type': 'stress', 'seq': 2}, {'text': 'a', 'seq': 3}, {'text': 'mus', 'seq': 4}]
>>> vb.hyphenation("amazing")
[{'text': 'a', 'seq': 0}, {'text': 'maz', 'type': 'stress', 'seq': 1}, {'text': 'ing', 'seq': 2}]
>>>

Help

If you need to see the usage for any of the methods, do a

>>> from vocabulary import Vocabulary as vb
>>> help(vb.meaning)
Help on function meaning in module vocabulary.vocabulary:

meaning(phrase, source_lang='en', dest_lang='en')
    make calls to the
    - glosbe API(default choice)
    - Wordnik API

    Wordnik's API gives less results so not Using it here for getting the meanings

    params:
    =======
    source_lang, dest_lang (both default to "en" if nothing is specified)

    Usage:
    ======
    >>> from vocabulary import Vocabulary as vb
    >>> vb.meaning("levitate")
    '[{"text": "(intransitive) Be suspended in the air, as if in defiance of gravity.", "seq": 0}, {"text": "(transitive) To cause to rise in the air and float, as if in defiance of gravity.", "seq": 1}]'
    >>>
(END)

and so on for other functions

How does it work

Under the hood, it makes use of 4 awesome API’s to give you consistent results. The API’s being

  • Urbandict

  • Glosbe

  • BighugeLabs

  • Wordnik

To do

  • Add translate module

Tests

Vocabulary uses unittesting for testing.

Run the test cases by doing a

$ ./tests.py -v
test_antonym_1 (__main__.TestModule) ... ok
test_antonym_2 (__main__.TestModule) ... ok
test_hyphenation (__main__.TestModule) ... ok
test_meaning (__main__.TestModule) ... ok
test_partOfSpeech_1 (__main__.TestModule) ... ok
test_partOfSpeech_2 (__main__.TestModule) ... ok
test_pronunciation (__main__.TestModule) ... ok
test_synonym (__main__.TestModule) ... ok
test_usageExamples (__main__.TestModule) ... ok

----------------------------------------------------------------------
Ran 9 tests in 7.742s

OK
(testvocab)

Contributing

Feel free to contribute

  1. Fork it.

  2. Create your feature branch (git checkout -b my-new-awesome-feature)

  3. Commit your changes (git commit -am 'Added <xyz> feature')

  4. Push to the branch (git push origin my-new-awesome-feature)

  5. Create new Pull Request

Bugs

Please report the bugs at the issue tracker

License :

MIT License © Tasdik Rahman

You can find a copy of the License at http://prodicus.mit-license.org/

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

Vocabulary-0.0.1.tar.gz (8.5 kB view details)

Uploaded Source

File details

Details for the file Vocabulary-0.0.1.tar.gz.

File metadata

  • Download URL: Vocabulary-0.0.1.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Vocabulary-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a6fc5d621a6b379afaa1a1c42a61474a3e6cadc019854ba52ceac1f27daab19b
MD5 2cd8f4af08fc43555468fa37be92136d
BLAKE2b-256 cb2bfa048bfc305d17c430da0f9f13ac382e3495e6ba1506e7be44c99fd6b84f

See more details on using hashes here.

Supported by

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