24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
lang = "${lang}"
locales = ${loc}
pkg = "${implname}"
name = "${name}"
version = "${version}"
author = "${author}"
# grammar rules and dictionary
_sContext = "" # what software is running
_rules = None # module gc_rules
_dOptions = None
_aIgnoredRules = set()
_oDict = None
_dAnalyses = {} # cache for data from dictionary
#### Parsing
def parse (sText, sCountry="${country_default}", bDebug=False, dOptions=None, bContext=False):
"analyses the paragraph sText and returns list of errors"
|
<
<
|
>
>
>
|
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
lang = "${lang}"
locales = ${loc}
pkg = "${implname}"
name = "${name}"
version = "${version}"
author = "${author}"
_rules = None # module gc_rules
# data
_sAppContext = "" # what software is running
_dOptions = None
_aIgnoredRules = set()
_oDict = None
_dAnalyses = {} # cache for data from dictionary
#### Parsing
def parse (sText, sCountry="${country_default}", bDebug=False, dOptions=None, bContext=False):
"analyses the paragraph sText and returns list of errors"
|
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
|
_createError = _createWriterError
except ImportError:
_createError = _createDictError
def load (sContext="Python"):
global _oDict
global _sContext
global _dOptions
try:
_oDict = IBDAWG("${dic_name}.bdic")
_sContext = sContext
_dOptions = dict(gc_options.getOptions(sContext)) # duplication necessary, to be able to reset to default
except:
traceback.print_exc()
def setOption (sOpt, bVal):
if sOpt in _dOptions:
|
|
|
|
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
_createError = _createWriterError
except ImportError:
_createError = _createDictError
def load (sContext="Python"):
global _oDict
global _sAppContext
global _dOptions
try:
_oDict = IBDAWG("${dic_name}.bdic")
_sAppContext = sContext
_dOptions = dict(gc_options.getOptions(sContext)) # duplication necessary, to be able to reset to default
except:
traceback.print_exc()
def setOption (sOpt, bVal):
if sOpt in _dOptions:
|
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
|
def getOptions ():
return _dOptions
def getDefaultOptions ():
return dict(gc_options.getOptions(_sContext))
def getOptionsLabels (sLang):
return gc_options.getUI(sLang)
def displayOptions (sLang):
echo("List of options")
echo("\n".join( [ k+":\t"+str(v)+"\t"+gc_options.getUI(sLang).get(k, ("?", ""))[0] for k, v in sorted(_dOptions.items()) ] ))
echo("")
def resetOptions ():
global _dOptions
_dOptions = dict(gc_options.getOptions(_sContext))
def getDictionary ():
return _oDict
def _getRules (bParagraph):
|
|
|
|
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
|
def getOptions ():
return _dOptions
def getDefaultOptions ():
return dict(gc_options.getOptions(_sAppContext))
def getOptionsLabels (sLang):
return gc_options.getUI(sLang)
def displayOptions (sLang):
echo("List of options")
echo("\n".join( [ k+":\t"+str(v)+"\t"+gc_options.getUI(sLang).get(k, ("?", ""))[0] for k, v in sorted(_dOptions.items()) ] ))
echo("")
def resetOptions ():
global _dOptions
_dOptions = dict(gc_options.getOptions(_sAppContext))
def getDictionary ():
return _oDict
def _getRules (bParagraph):
|