Ejemplo n.º 1
0
def search_dictionary(msg):
    """Get word meaning, synonym, antonym and translation."""
    lt_w = msg.split(' ')
    dictionary = PyDictionary(lt_w[-1])
    stre = lt_w[-1]
    if 'meaning' in lt_w:
        stre += '\n' + str(dictionary.getMeanings()[lt_w[-1]])
        if 'synonym' in lt_w:
            stre += '\n' + str(dictionary.getSynonyms()[0][lt_w[-1]])
        if 'antonym' in lt_w:
            stre += '\n' + str(dictionary.getAntonyms()[0][lt_w[-1]])
        if 'translate' in lt_w:
            stre += '\n' + dictionary.translateTo(
                lt_w[lt_w.index('translate') + 1])[0]

    return RESPONSE_TYPE['MESSAGE'], stre
Ejemplo n.º 2
0
from PyDictionary import PyDictionary

dictionary = PyDictionary()
print(dictionary.meaning("indentation"))
print(dictionary.synonym("life"))
print(dictionary.antonym("paper"))
print(dictionary.translate("extreme", 'es'))

dictionary = PyDictionary("hotel", "ambush", "nonchalant", "perceptive")
'There can be any number of words in the Instance'

print(dictionary.printMeanings()
      )  # '''This print the meanings of all the words'''
print(dictionary.getMeanings()
      )  # '''This will return meanings as dictionaries'''
print(dictionary.getSynonyms())

print(dictionary.translateTo(
    "hi"))  # '''This will translate all words to Hindi'''