Skip to main content

PyMultiDictionary is a Dictionary Module for Python 2 to get meanings, translations, synonyms and antonyms of words in 20 different languages

Project description

@ppizarror License MIT Python 3.7+ PyPi package Build status FOSSA Status Codecov Open issues PyPi downloads Total downloads Buy me a Ko-fi

PyMultiDictionary is a dictionary module for Python 3+ to get meanings, translations, synonyms and antonyms of words in 20 different languages. It uses educalingo.com, synonym.com, and WordNet for getting meanings, translations, synonyms, and antonyms.

Supported languages

  • Bengali (bn)

  • German (de)

  • English (en)

  • Spanish (es)

  • French (fr)

  • Hindi (hi)

  • Italian (it)

  • Japanese (ja)

  • Javanese (jv)

  • Korean (ko)

  • Marathi (mr)

  • Malay (ms)

  • Polish (pl)

  • Portuguese (pt)

  • Romanian (ro)

  • Russian (ru)

  • Tamil (ta)

  • Turkish (tr)

  • Ukranian (uk)

  • Chinese (zh)

Install Instructions

PyMultiDictionary can be installed via pip, for both MacOS, Windows & Linux. Simply run:

$> python3 -m pip install --upgrade PyMultiDictionary

Usage

PyMultiDictionary can be utilized in 2 ways, either by creating a dictionary instance which can take words as arguments or by creating a dictionary instance with a fixed amount of words.

Create a dictionary object:

For example,

from PyMultiDictionary import MultiDictionary
dictionary = MultiDictionary()

This will create a local instance of the MultiDictionary class, and now it can be used to get meanings, translations, etc.

For Meanings,

print(dictionary.meaning('en', 'good'))

This will return a tuple containing the meanings of the word, in the format (word_type, word_meaning, word_wikipedia). For example, the above code will return:

(['Noun', 'Adjective', 'Exclamation'],
 'The first definition of good in the dictionary is having admirable  ...',
 'Good may refer to: ▪ Good and evil, the distinction between positive...')

All methods support other dictionaries, for example, ‘wordnet’ can be used for English words.

from PyMultiDictionary import DICT_WORDNET
dictionary = MultiDictionary()
print(dictionary.meaning('en', 'good', dictionary=DICT_WORDNET))

Will return:

{
    'Noun': ['benefit', 'moral excellence or admirableness', ...],
    'Adjective': ['morally admirable', ...],
    'Adverb': [...]
}

For Synonyms,

print(dictionary.synonym('es', 'Bueno'))

This will return a list containing the Synonyms of the word.

For Antonyms,

print(dictionary.antonym('en', 'Life'))

This will return a list containing the Antonyms of the word. Currently, only English is supported.

For Translations,

print(dictionary.translate('en', 'Range'))

This will return the word ‘Range’ translation in 20 different languages. You can also extend the scope of the translations by providing a target language, which will use Google Translate API, for example:

print(dictionary.translate('en', 'Range', to='ru'))

Alternatively, you can set a fixed number of words to the Dictionary Instance. This is helpful if you want to get the meanings of some words quickly without any development need.

Example:

from PyMultiDictionary import MultiDictionary, DICT_EDUCALINGO

dictionary=MultiDictionary('hotel', 'ambush', 'nonchalant', 'perceptive')
dictionary.set_words_lang('en') # All words are English

print(dictionary.get_meanings(dictionary=DICT_EDUCALINGO)) # This print the meanings of all the words
print(dictionary.get_synonyms()) # Get synonyms list
print(dictionary.get_antonyms()) # Get antonyms
print(dictionary.get_translations()) # This will translate all words to over 20 languages
print(dictionary.get_translations(to='ru')) # This will translate all words to Russian (if Google API is available)

Supported dictionaries

  • DICT_EDUCALINGO: Meaning, synonym, translation for all languages

  • DICT_SYNONYMCOM: Synonyms and Antonyms (English)

  • DICT_THESAURUS: Synonyms (English)

  • DICT_WORDNET: Meanings (English)

There are many more dictionaries to come. Just contribute to this repo!

Author

Pablo Pizarro R. | 2021 - 2024

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

pymultidictionary-1.2.5.tar.gz (24.3 kB view details)

Uploaded Source

Built Distribution

PyMultiDictionary-1.2.5-py3-none-any.whl (23.2 kB view details)

Uploaded Python 3

File details

Details for the file pymultidictionary-1.2.5.tar.gz.

File metadata

  • Download URL: pymultidictionary-1.2.5.tar.gz
  • Upload date:
  • Size: 24.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.20

File hashes

Hashes for pymultidictionary-1.2.5.tar.gz
Algorithm Hash digest
SHA256 df60867c3cdad328e461a619a3c45f0ac147f90f62a28d4a1ba6d248c755acc0
MD5 65f4d1dad54aa6b584eb87f41009e096
BLAKE2b-256 3389cd0443263adc017ad6909195540f44ce410713db5825806604f178c548e0

See more details on using hashes here.

Provenance

File details

Details for the file PyMultiDictionary-1.2.5-py3-none-any.whl.

File metadata

File hashes

Hashes for PyMultiDictionary-1.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b7446e0b5e8344ecad5718776c8ad3e604ad521f8c33b4cf80c3201a5c5d8496
MD5 387fb3b1e4320634edd478986a5f2014
BLAKE2b-256 b653bd2124cf5c1eb9943f813d1cd4da071a3a91170be5e024332a17f38c0a93

See more details on using hashes here.

Provenance

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