|
6 | 6 |
|
7 | 7 | PyDictAPI is library written in Python, that can be used to fetch meanings and translation.
|
8 | 8 |
|
| 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 | +
|
9 | 12 | Currently supports only English-English dictionary searches
|
10 | 13 |
|
11 | 14 | Basic usage:
|
12 | 15 |
|
13 | 16 | >>> from PyDictAPI import Finder
|
14 |
| - >>> Meanings = Finder() |
| 17 | + >>> Meanings = Finder(jsonify=True) |
15 | 18 | >>> print(Meanings.findMeanings('apple'))
|
16 | 19 |
|
17 | 20 | Output:
|
18 | 21 |
|
19 | 22 | `{
|
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 | + ] |
39 | 34 | }`
|
| 35 | +
|
40 | 36 | ---------------------------------------
|
41 | 37 | Finding Examples, Synonyms and Antonyms
|
42 | 38 | ---------------------------------------
|
|
53 | 49 | Translating text
|
54 | 50 | ----------------
|
55 | 51 |
|
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")) |
67 | 64 |
|
68 | 65 | `{'query': 'Hello, How are you?', 'language_detected': 'Hindi', 'translation': 'नमस्कार किसे हो आप?'}`
|
69 | 66 |
|
|
0 commit comments