Skip to content

Commit 7b38912

Browse files
committed
Update class documentations
1 parent f7b8eb1 commit 7b38912

File tree

2 files changed

+36
-40
lines changed

2 files changed

+36
-40
lines changed

PyDictAPI/__init__.py

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,33 @@
66
77
PyDictAPI is library written in Python, that can be used to fetch meanings and translation.
88
9+
Both the Finder and Translator class takes an arguement "jsonify" that is set to False by default.
10+
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)
11+
912
Currently supports only English-English dictionary searches
1013
1114
Basic usage:
1215
1316
>>> from PyDictAPI import Finder
14-
>>> Meanings = Finder()
17+
>>> Meanings = Finder(jsonify=True)
1518
>>> print(Meanings.findMeanings('apple'))
1619
1720
Output:
1821
1922
`{
20-
'word': 'apple',
21-
'meanings': [
22-
{
23-
'partOfSpeech': 'noun',
24-
'definitions': [
25-
{
26-
'definition': 'the usually round, red or yellow, edible fruit of a small tree, Malus sylvestris, of the rose family.'
27-
}
28-
]
29-
},
30-
{
31-
'partOfSpeech': 'noun',
32-
'definitions': [
33-
{
34-
'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'
35-
}
36-
]
37-
}
38-
]
23+
"word": "Apple",
24+
"meanings": [
25+
{
26+
"partOfSpeech": "Noun",
27+
"definition": "The usually round, red or yellow, edible fruit of a small tree, Malus sylvestris, of the rose family."
28+
},
29+
{
30+
"partOfSpeech": "Noun",
31+
"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"
32+
}
33+
]
3934
}`
35+
4036
---------------------------------------
4137
Finding Examples, Synonyms and Antonyms
4238
---------------------------------------
@@ -53,17 +49,18 @@
5349
Translating text
5450
----------------
5551
56-
### Example:
57-
>>> # Import the module first
58-
>>> from PyDictAPI import Translate
59-
>>> t = Translate() # Creates an instance of Translate class
60-
>>>
61-
>>> # You can get all supported language list through languages_help()
62-
>>> languages = t.languages_help(pretty=True)
63-
>>> # Pretty=true returns the list of supported languages in a well structured manner. By default Pretty is set to False
64-
>>>
65-
>>> # Tranlate English into Hindi
66-
>>> print(t.translateItems("Hello, How are you?", "hi"))
52+
Example:
53+
54+
>>> # Import the module first
55+
>>> from PyDictAPI import Translate
56+
>>> t = Translate(jsonify=True) # Creates an instance of Translate class
57+
>>>
58+
>>> # You can get all supported language list through languages_help()
59+
>>> languages = t.languages_help(pretty=True)
60+
>>> # Pretty=true returns the list of supported languages in a well structured manner. By default Pretty is set to False
61+
>>>
62+
>>> # Tranlate English into Hindi
63+
>>> print(t.translateItems("Hello, How are you?", "hi"))
6764
6865
`{'query': 'Hello, How are you?', 'language_detected': 'Hindi', 'translation': 'नमस्कार किसे हो आप?'}`
6966

PyDictAPI/translator.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ class Translate(object):
2727
### Example:
2828
>>> # Import the module first
2929
>>> from PyDictAPI import Translate
30-
>>> t = Translate() # Creates an instance of Translate class
31-
>>>
30+
>>> t = Translate(jsonify=True) # Creates an instance of Translate class
31+
>>> # jsonify=True returns response in JSON, and by default jsonify is False
3232
>>> # You can get all supported language list through languages_help()
33-
>>> languages = t.languages_help(pretty=True)
34-
>>> # Pretty=true returns the list of supported languages in a well structured manner. By default Pretty is set to False
33+
>>> languages = t.languages_help())
3534
>>>
3635
>>> # Tranlate English into Hindi
3736
>>> print(t.translateItems("Hello, How are you?", "hi"))
@@ -73,11 +72,11 @@ def languages_help(self):
7372
:Example:
7473
7574
>>> from PyDictAPI import Translate
76-
>>> t = Translate()
77-
>>> print(t.languages_help(pretty=True))
75+
>>> t = Translate(jsonify=True)
76+
>>> print(t.languages_help())
7877
79-
pretty=False returns a json response,
80-
and by default pretty is False, use pretty=True for pretty print
78+
jsonify=True returns a json response,
79+
and by default jsonify is False
8180
8281
'''
8382

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

0 commit comments

Comments
 (0)