Skip to content

Commit

Permalink
Update class documentations
Browse files Browse the repository at this point in the history
  • Loading branch information
imshawan committed Sep 3, 2021
1 parent f7b8eb1 commit 7b38912
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 40 deletions.
59 changes: 28 additions & 31 deletions PyDictAPI/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,33 @@
PyDictAPI is library written in Python, that can be used to fetch meanings and translation.
Both the Finder and Translator class takes an arguement "jsonify" that is set to False by default.
If jsonify is set to True, than the processed queries are returned in JSON. While by default the queries are returned in the form of a Python List (Array)
Currently supports only English-English dictionary searches
Basic usage:
>>> from PyDictAPI import Finder
>>> Meanings = Finder()
>>> Meanings = Finder(jsonify=True)
>>> print(Meanings.findMeanings('apple'))
Output:
`{
'word': 'apple',
'meanings': [
{
'partOfSpeech': 'noun',
'definitions': [
{
'definition': 'the usually round, red or yellow, edible fruit of a small tree, Malus sylvestris, of the rose family.'
}
]
},
{
'partOfSpeech': 'noun',
'definitions': [
{
'definition': 'a rosaceous tree, Malus sieversii, native to Central Asia but widely cultivated in temperate regions in many varieties, having pink or white fragrant flowers and firm rounded edible fruits'
}
]
}
]
"word": "Apple",
"meanings": [
{
"partOfSpeech": "Noun",
"definition": "The usually round, red or yellow, edible fruit of a small tree, Malus sylvestris, of the rose family."
},
{
"partOfSpeech": "Noun",
"definition": "A rosaceous tree, Malus sieversii, native to Central Asia but widely cultivated in temperate regions in many varieties, having pink or white fragrant flowers and firm rounded edible fruits. See also crab apple"
}
]
}`
---------------------------------------
Finding Examples, Synonyms and Antonyms
---------------------------------------
Expand All @@ -53,17 +49,18 @@
Translating text
----------------
### Example:
>>> # Import the module first
>>> from PyDictAPI import Translate
>>> t = Translate() # Creates an instance of Translate class
>>>
>>> # You can get all supported language list through languages_help()
>>> languages = t.languages_help(pretty=True)
>>> # Pretty=true returns the list of supported languages in a well structured manner. By default Pretty is set to False
>>>
>>> # Tranlate English into Hindi
>>> print(t.translateItems("Hello, How are you?", "hi"))
Example:
>>> # Import the module first
>>> from PyDictAPI import Translate
>>> t = Translate(jsonify=True) # Creates an instance of Translate class
>>>
>>> # You can get all supported language list through languages_help()
>>> languages = t.languages_help(pretty=True)
>>> # Pretty=true returns the list of supported languages in a well structured manner. By default Pretty is set to False
>>>
>>> # Tranlate English into Hindi
>>> print(t.translateItems("Hello, How are you?", "hi"))
`{'query': 'Hello, How are you?', 'language_detected': 'Hindi', 'translation': 'नमस्कार किसे हो आप?'}`
Expand Down
17 changes: 8 additions & 9 deletions PyDictAPI/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@ class Translate(object):
### Example:
>>> # Import the module first
>>> from PyDictAPI import Translate
>>> t = Translate() # Creates an instance of Translate class
>>>
>>> t = Translate(jsonify=True) # Creates an instance of Translate class
>>> # jsonify=True returns response in JSON, and by default jsonify is False
>>> # You can get all supported language list through languages_help()
>>> languages = t.languages_help(pretty=True)
>>> # Pretty=true returns the list of supported languages in a well structured manner. By default Pretty is set to False
>>> languages = t.languages_help())
>>>
>>> # Tranlate English into Hindi
>>> print(t.translateItems("Hello, How are you?", "hi"))
Expand Down Expand Up @@ -73,11 +72,11 @@ def languages_help(self):
:Example:
>>> from PyDictAPI import Translate
>>> t = Translate()
>>> print(t.languages_help(pretty=True))
>>> t = Translate(jsonify=True)
>>> print(t.languages_help())
pretty=False returns a json response,
and by default pretty is False, use pretty=True for pretty print
jsonify=True returns a json response,
and by default jsonify is False
'''

Expand Down Expand Up @@ -109,7 +108,7 @@ def translateItems(self, query, translateLang="auto", from_lang="auto"):
### Example:
>>> # Import the module first
>>> from PyDictAPI import Translate
>>> t = Translate() # Creates an instance of Translate class
>>> t = Translate(jsonify=true) # Creates an instance of Translate class
>>>
>>> # Tranlate English into Hindi
>>> print(t.translateItems("Hello, How are you?", "hi"))
Expand Down

0 comments on commit 7b38912

Please sign in to comment.