Skip to main content

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.'
...

Package version


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


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

mldictionary-0.0.5-py3-none-any.whl (5.4 kB view hashes)

Uploaded Python 3

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