355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
|
sDescription = dVars['dic_personal_description']
lex_build.build(spfLexSrc, dVars['lang'], dVars['lang_name'], sfDictDst, bJavaScript, sDicName, sDescription, "", dVars['stemming_method'], int(dVars['fsa_method']))
def extraTest (sLang):
"test grammar checker with files in <gc_lang/xx/tests>"
if os.path.isdir(f"gc_lang/{sLang}/tests"):
grammalecte = importlib.import_module("grammalecte")
oGrammarChecker = grammalecte.GrammarChecker(sLang)
for sf in os.listdir(f"gc_lang/{sLang}/tests"):
if sf.startswith("test_") and sf.endswith(".txt"):
spf = f"gc_lang/{sLang}/tests/" + sf
with open(spf, "r", encoding="utf-8") as hSrc:
print(f"> Test text: {spf}", end="")
nLine = sum(1 for _ in hSrc)
nPercent = max(nLine // 100, 1)
hSrc.seek(0) # rewind to start of file
for i, sLine in enumerate(hSrc, 1):
if (i % nPercent == 0):
print(f"\r> Test text: {spf} ({i // nPercent} %)", end="")
aGrammErrs, aSpellErrs = oGrammarChecker.getParagraphErrors(sLine)
if aGrammErrs:
sText, _ = grammalecte.text.generateParagraph(sLine, aGrammErrs, aSpellErrs, 160)
print(f"\n# Line {i}")
print(sText)
print(f"\r> Test text: {spf} ({i // nPercent} %): {i} lines.")
else:
print(f"# Error. No folder <gc_lang/{sLang}/tests>. With option -tt, all texts named <test_*.txt> in this folder will be parsed by the grammar checker.")
def main ():
"build Grammalecte with requested options"
print("Python: " + sys.version)
|
>
|
|
>
>
|
|
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
|
sDescription = dVars['dic_personal_description']
lex_build.build(spfLexSrc, dVars['lang'], dVars['lang_name'], sfDictDst, bJavaScript, sDicName, sDescription, "", dVars['stemming_method'], int(dVars['fsa_method']))
def extraTest (sLang):
"test grammar checker with files in <gc_lang/xx/tests>"
if os.path.isdir(f"gc_lang/{sLang}/tests"):
print(">>>>>>>>>> EXTRA TESTS: parsing texts in <gc_lang/{sLang}/tests>\n")
grammalecte = importlib.import_module("grammalecte")
oGrammarChecker = grammalecte.GrammarChecker(sLang)
for sf in os.listdir(f"gc_lang/{sLang}/tests"):
if sf.startswith("test_") and sf.endswith(".txt"):
spf = f"gc_lang/{sLang}/tests/" + sf
with open(spf, "r", encoding="utf-8") as hSrc:
print(f"\n>>>>>>>>>> TEST TEXT: {spf} <<<<<<<<<<\n")
nLine = sum(1 for _ in hSrc)
nPercent = max(nLine // 100, 1)
hSrc.seek(0) # rewind to the beginning of the file
nTotError = 0
for i, sLine in enumerate(hSrc, 1):
if (i % nPercent == 0):
print(f"\r> Test text: {spf} ({i // nPercent} %)", end="")
aGrammErrs, aSpellErrs = oGrammarChecker.getParagraphErrors(sLine)
if aGrammErrs:
sText, _ = grammalecte.text.generateParagraph(sLine, aGrammErrs, aSpellErrs, 160)
print(f"\n# Line {i}")
print(sText)
nTotError += 1
print(f"\r> Test text: {spf} ({i // nPercent} %): {i} lines. Grammar errors in {nTotError} lines.")
else:
print(f"# Error. No folder <gc_lang/{sLang}/tests>. With option -tt, all texts named <test_*.txt> in this folder will be parsed by the grammar checker.")
def main ():
"build Grammalecte with requested options"
print("Python: " + sys.version)
|