pycrossword
0.4
Pure-Python implementation of a crossword puzzle generator and editor
|
Base (abstract) class for online dictionaries. More...
Public Member Functions | |
def | __init__ (self, settings, url_template='', timeout=5000) |
def | prepare_request_url (self, word) |
Constructs the search URL given a search word. More... | |
def | get_definitions (self, word, method='json') |
Returns full definitions for 'word' in JSON (python object) or raw text format. More... | |
def | get_short_defs (self, word, exact_match=True, partsofspeech=None, bad_pos='UNKNOWN') |
Returns the abridged definition for the given entry. More... | |
Public Attributes | |
url | |
str‘ search URL template with placeholders (’{}') for parameters More... | |
timeout | |
int network request timeout (in msec.) More... | |
settings | |
dict stored pointer to app global settings More... | |
Base (abstract) class for online dictionaries.
def pycross.utils.onlineservices.OnlineDictionary.__init__ | ( | self, | |
settings, | |||
url_template = '' , |
|||
timeout = 5000 |
|||
) |
settings | dict pointer to the app settings dictionary (pycross::guisettings::CWSettings::settings ) |
url_template | str search URL template with placeholders ('{}') for parameters |
timeout | int network request timeout (in msec.) |
Reimplemented in pycross.utils.onlineservices.YandexDict.
def pycross.utils.onlineservices.OnlineDictionary.get_definitions | ( | self, | |
word, | |||
method = 'json' |
|||
) |
Returns full definitions for 'word' in JSON (python object) or raw text format.
word | str search word |
method | str parsing method to parse the results |
dict
| str
search results; if method
== 'json' (default), the results are parsed as a JSON-formatted string into a Python dictionary object. Otherwise, the raw result string is returned. def pycross.utils.onlineservices.OnlineDictionary.get_short_defs | ( | self, | |
word, | |||
exact_match = True , |
|||
partsofspeech = None , |
|||
bad_pos = 'UNKNOWN' |
|||
) |
Returns the abridged definition for the given entry.
word | str the word query |
exact_match | bool if True , only defitions for the exact word given by word will be returned |
partsofspeech | list |tuple parts of speech to get definitions for (None = all available) |
bad_pos | str substitution for part of speech if unavailable |
list
list of short definitions in the format: Reimplemented in pycross.utils.onlineservices.YandexDict, and pycross.utils.onlineservices.MWDict.
def pycross.utils.onlineservices.OnlineDictionary.prepare_request_url | ( | self, | |
word | |||
) |
Constructs the search URL given a search word.
word | str search word |
str
prepared search URL Reimplemented in pycross.utils.onlineservices.YandexDict, and pycross.utils.onlineservices.MWDict.
pycross.utils.onlineservices.OnlineDictionary.settings |
dict
stored pointer to app global settings
pycross.utils.onlineservices.OnlineDictionary.timeout |
int
network request timeout (in msec.)
pycross.utils.onlineservices.OnlineDictionary.url |
str‘ search URL template with placeholders (’{}') for parameters