PyMultiDictionary is a Dictionary Module for Python 2 to get meanings, translations, synonyms and antonyms of words in 20 different languages
Project description
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 utilised 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 is 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 positiv...')
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 Translation of the word ‘Range’ in 20 different languages. You can also extendthe 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 useful if you just 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 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 much more dictionaries to come. Just contribute to this repo!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for PyMultiDictionary-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4209b582b987c140e760487dd7590bfe1ccd359d1055285ef141992ac4e19ebb |
|
MD5 | 61292847691651126db6188f4a2eb999 |
|
BLAKE2b-256 | 6df7d4cd0c59cb7971a1d4f0f0bfb05313015d0baff34c112400a5182022b6e2 |