word's dictionary for several languages
Project description
MLDictionary
MLDictionary is word's dictionary for several language
>>> from mldictionary import English
>>> english_dictionary = English()
>>> snake_means = english_dictionary.get_meanings('snake')
>>> len(snake_means)
4
>>> snake_means
['a reptile with a long body and no legs: ' ...]
...
Installing MLDictionary
$ pip install mldictionary
MLDictionary officially supports 3.9+.
Some examples
>>> from mldictionary import Portuguese
>>> portuguese_dictionary = Portuguese()
>>> vida_means = portuguese_dictionary.get_meanings('vida')
>>> vida_means
['Conjunto dos hábitos e costumes de alguém; maneira de viver: tinha uma vida de milionário.' ...]
>>> from mldictionary import Spanish
>>> spanish_dictionary = Spanish()
>>> coche_means = spanish_dictionary.get_meanings('coche')
>>> coche_means
['1. m. Automóvil destinado al transporte de personas y con capacidad no superior a siete plazas.' ...]
Make your own dictionary
from typing import List
from mldictionary import Dictionary
class MyOwnDictionary(Dictionary):
URL = 'somedictionary.com' #required
LANGUAGE = 'language name' #requerid
TARGET_TAG = 'tag_where_means_is' #depend if you're gonna overwrite _soup_meanings method
TARGET_ATTR = {'attr': 'attr_value'} #depend if you're gonna overwrite _soup_meanings method
@classmethod
def _soup_meanings(cls, html_tree: str)->List[str]: #optional
'''
Method to overwrite the meanings select by Dictionary class;
Used when you wanna change something which comes with the meanings
'''
>>> myowndictionary = MyOwnDictionary()
>>> myowndictionary.get_meanings('other language word')
To more details, see the wiki
Also, it has a insightful article on linkedin
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
mldictionary-0.1.11.tar.gz
(4.8 kB
view hashes)
Built Distribution
Close
Hashes for mldictionary-0.1.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dea4e2daf60ce083a9e63d9c2a56778ce87fc952fef717e28c61330f2896c81 |
|
MD5 | 5687cfd0c29816f61edc877fbb5346b1 |
|
BLAKE2b-256 | ad5cfaf8ddd6dc3d24b2a975470321f07380ba1b732dc79865b54e7d4aa5d4e0 |