pycrossword
0.4
Pure-Python implementation of a crossword puzzle generator and editor
|
Public Member Functions | |
def | __init__ (self, settings, dbmanager=None, dicfolder=DICFOLDER) |
def | pool_running (self) |
def | pool_threadcount (self) |
def | pool_wait (self) |
def | get_installed_info (self, lang) |
def | list_hunspell (self, stopcheck=None) |
Retrieves the list of Hunspell dictionaries available for download from the public Github repo. More... | |
def | list_all_dics (self, stopcheck=None) |
def | download_hunspell (self, url, lang, overwrite=True, on_stopcheck=None, on_start=None, on_getfilesize=None, on_progress=None, on_complete=None, on_error=None, wait=False) |
def | download_hunspell_all (self, dics, on_stopcheck=None, on_start=None, on_getfilesize=None, on_progress=None, on_complete=None, on_error=None) |
def | standard_posrules (self, lang) |
Returns the default Hunspell-formatted metadata patterns for the three common parts of speech (noun, verb, adjective). More... | |
def | standard_replacements (self, lang) |
Returns the default replacement rules for a language to use in Hunspell imports. More... | |
def | add_from_hunspell (self, lang, posrules=None, posrules_strict=False, posdelim='/', lcase=True, replacements=None, remove_hyphens=True, filter_out=None, rows=None, commit_each=1000, on_checkstop=None, on_start=None, on_word=None, on_commit=None, on_finish=None, on_error=None, wait=False) |
Imports a Hunspell-formatted dictionary file into the DB. More... | |
def | add_all_from_hunspell (self, dics, posrules=None, posrules_strict=True, posdelim='/', lcase=True, replacements=None, remove_hyphens=True, filter_out=None, rows=None, commit_each=1000, on_stopcheck=None, on_start=None, on_word=None, on_commit=None, on_finish=None, on_error=None) |
Imports all Hunspell-formatted dictionaries found in 'assets/dic'. More... | |
Public Attributes | |
settings | |
db | |
dicfolder | |
pool | |
timeout_ | |
proxies_ | |
def pycross.dbapi.HunspellImport.__init__ | ( | self, | |
settings, | |||
dbmanager = None , |
|||
dicfolder = DICFOLDER |
|||
) |
def pycross.dbapi.HunspellImport.add_all_from_hunspell | ( | self, | |
dics, | |||
posrules = None , |
|||
posrules_strict = True , |
|||
posdelim = '/' , |
|||
lcase = True , |
|||
replacements = None , |
|||
remove_hyphens = True , |
|||
filter_out = None , |
|||
rows = None , |
|||
commit_each = 1000 , |
|||
on_stopcheck = None , |
|||
on_start = None , |
|||
on_word = None , |
|||
on_commit = None , |
|||
on_finish = None , |
|||
on_error = None |
|||
) |
Imports all Hunspell-formatted dictionaries found in 'assets/dic'.
dics | iterable list of dict containing language info (others found will be skipped). Default = None (import all found dictionaries) |
def pycross.dbapi.HunspellImport.add_from_hunspell | ( | self, | |
lang, | |||
posrules = None , |
|||
posrules_strict = False , |
|||
posdelim = '/' , |
|||
lcase = True , |
|||
replacements = None , |
|||
remove_hyphens = True , |
|||
filter_out = None , |
|||
rows = None , |
|||
commit_each = 1000 , |
|||
on_checkstop = None , |
|||
on_start = None , |
|||
on_word = None , |
|||
on_commit = None , |
|||
on_finish = None , |
|||
on_error = None , |
|||
wait = False |
|||
) |
Imports a Hunspell-formatted dictionary file into the DB.
Hunspell dictionaries can be downloaded from LibreOffice or Github. Default dictionaries and prebuilt SQLite databases are found in assets/dic.
lang | str short name of the imported dictionary language, e.g. 'en', 'de' etc. |
posrules | dict part-of-speech regular expression parsing rules in the format: {'N': 'regex for nouns', 'V': 'regex for verb', ...}
Possible keys are: 'N' [noun], 'V' [verb], 'ADV' [adverb], 'ADJ' [adjective], 'P' [participle], 'PRON' [pronoun], 'I' [interjection], 'C' [conjuction], 'PREP' [preposition], 'PROP' [proposition], 'MISC' [miscellaneous / other], 'NONE' [no POS] |
posrules_strict | bool if True (default), only the parts of speech present in posrules dict will be imported [all other words will be skipped]. If False , such words will be imported with 'MISC' and 'NONE' POS markers. |
posdelim | str delimiter delimiting the word and its part of speech [default = '/'] |
lcase | bool if True (default), found words will be imported in lower case; otherwise, the original case will remain |
replacements | dict : character replacement rules in the format: {'char_from': 'char_to', ...}
None (no replacements) |
remove_hyphens | bool if True (default), all hyphens ['-'] will be removed from the words |
filter_out | dict regex-based rules to filter out [exclude] words in the format: {'word': ['regex1', 'regex2', ...], 'pos': ['regex1', 'regex2', ...]}
None (no filter rules apply). |
commit_each | int threshold of insert operations after which the transaction will be committed (default = 1000) |
on_word | callable callback function to be called when a word is imported into the DB. Callback prototype is: on_word(lang: str, dicfile: str, word: str, part_of_speech: str, records_committed: int) -> None
|
on_commit | callable callback function to be called when a next portion of records is written to the DB. Callback prototype is: on_commit(lang: str, dicfile: str, records_committed: int) -> None
|
int
number of words imported from the dictionary on_error | callable callback function to be called when an exception occurs Callback prototype is: on_error(lang: str, dicfile: str, error_message: str) -> None
|
def pycross.dbapi.HunspellImport.download_hunspell | ( | self, | |
url, | |||
lang, | |||
overwrite = True , |
|||
on_stopcheck = None , |
|||
on_start = None , |
|||
on_getfilesize = None , |
|||
on_progress = None , |
|||
on_complete = None , |
|||
on_error = None , |
|||
wait = False |
|||
) |
def pycross.dbapi.HunspellImport.download_hunspell_all | ( | self, | |
dics, | |||
on_stopcheck = None , |
|||
on_start = None , |
|||
on_getfilesize = None , |
|||
on_progress = None , |
|||
on_complete = None , |
|||
on_error = None |
|||
) |
def pycross.dbapi.HunspellImport.get_installed_info | ( | self, | |
lang | |||
) |
def pycross.dbapi.HunspellImport.list_all_dics | ( | self, | |
stopcheck = None |
|||
) |
def pycross.dbapi.HunspellImport.list_hunspell | ( | self, | |
stopcheck = None |
|||
) |
Retrieves the list of Hunspell dictionaries available for download from the public Github repo.
def pycross.dbapi.HunspellImport.pool_running | ( | self | ) |
def pycross.dbapi.HunspellImport.pool_threadcount | ( | self | ) |
def pycross.dbapi.HunspellImport.pool_wait | ( | self | ) |
def pycross.dbapi.HunspellImport.standard_posrules | ( | self, | |
lang | |||
) |
Returns the default Hunspell-formatted metadata patterns for the three common parts of speech (noun, verb, adjective).
The returned patterns depend on the language.
lang | str language for which the matching patterns are requested, e.g. 'en' or 'ru' |
dict
POS to regex pattern matching table in the format: None
is returned.def pycross.dbapi.HunspellImport.standard_replacements | ( | self, | |
lang | |||
) |
Returns the default replacement rules for a language to use in Hunspell imports.
lang | str language for which the matching patterns are requested, e.g. 'en' or 'ru' |
dict
default replacements in the format: None
is returned.pycross.dbapi.HunspellImport.db |
pycross.dbapi.HunspellImport.dicfolder |
pycross.dbapi.HunspellImport.pool |
pycross.dbapi.HunspellImport.proxies_ |
pycross.dbapi.HunspellImport.settings |
pycross.dbapi.HunspellImport.timeout_ |