12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
+
+
|
import re
import traceback
import grammalecte
import grammalecte.text as txt
import grammalecte.graphspell.str_transform as strt
from grammalecte.graphspell.echo import echo
import grammalecte.fr.thesaurus as thes
_EXAMPLE = "Quoi ? Racontes ! Racontes-moi ! Bon sangg, parles ! Oui. Il y a des menteur partout. " \
"Je suit sidéré par la brutales arrogance de cette homme-là. Quelle salopard ! Un escrocs de la pire espece. " \
"Quant sera t’il châtiés pour ses mensonge ? Merde ! J’en aie marre."
_HELP = """
Analysis commands:
any_text grammar checking
?word1 [word2] ... words analysis
!word spelling suggestion
>word draw path of word in the word graph
=[filter1][=[filter2]] show entries which fit to filters (filter1 for word, filter2 for morphology)
≠word1 word2 [word3] ... show distance between words
$some_text show sentences and tokens of text
#word1 [word2] ... get synonyms of words
Other commands:
/help /h show this text
/lopt /lo list options
/lrules [pattern] /lr list rules
/o+ option1 [option2] ... activate grammar checking options
/o- option1 [option2] ... deactivate grammar checking options
|
313
314
315
316
317
318
319
320
321
322
323
324
325
326
|
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
|
+
+
+
+
+
+
+
+
+
+
+
|
# distances calculation
lWords = sText[1:].split()
for s1, s2 in itertools.combinations(lWords, 2):
strt.showDistance(s1, s2)
if xArgs.debug:
strt.showDistance(strt.simplifyWord(s1), strt.simplifyWord(s2))
echo("")
elif sText.startswith("#"):
# synonyms
lWords = sText[1:].split()
for sWord in lWords:
lSyns = thes.getSyns(sWord)
if lSyns:
echo(f"\n{sWord}")
for sCat, lSyn in lSyns:
echo(f"> {sCat} : " + " | ".join(lSyn))
else:
echo(f"\n{sWord}: pas de synonymes trouvés")
elif sText.startswith("/o+ "):
oGrammarChecker.gce.setOptions({ opt:True for opt in sText[3:].strip().split() if opt in oGrammarChecker.gce.getOptions() })
echo("done")
elif sText.startswith("/o- "):
oGrammarChecker.gce.setOptions({ opt:False for opt in sText[3:].strip().split() if opt in oGrammarChecker.gce.getOptions() })
echo("done")
elif sText.startswith("/r- "):
|