word's dictionary for several language
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
'1°: 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
'1º: 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()
>>> yo_means = spanish_dictionary.get_meanings('yo')
>>> yo_means
'1º: pron. Forma del pron. pers. com. de primera persona singular,' (...)
Make your own dictionary
import re # to take html tags out with regex
from typing import List, Union
from mldictionary import Dictionary
class MyOwnDictionary(Dictionary):
URL = 'somedictionary.com' #required
XPATH = '//xpath//of[@class="means"]' #required
LANGUAGE = 'language name' #requerid
@classmethod
def _clean_html(cls, meanings_html: List[str])->Union[str, bool]:
'''
method to take html tags out, for some examples, access:
https://github.com/PabloEmidio/mldictionary/tree/main/mldictionary
'''
>>> myowndictionary = MyOwnDictionary()
>>> myowndictionary.get_meanings('other language word')
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
Close
Hashes for mldictionary-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fd9d6f9d8b86a09bdeefbf6716eb8f38d3c09896cfbf25343e0d2c216b946bc9 |
|
MD5 | e982a8c35342556c18ed83e6ec600f07 |
|
BLAKE2b-256 | 347ad6981766d5c97dc9aae6fa54e7852b0fc39219987a78e2ce8b55a8260b98 |