Grammalecte  Diff

Differences From Artifact [16fbb68f36]:

To Artifact [19972ccb9a]:


81
82
83
84
85
86
87

88
89
90
91
92

93
94
95
96
97
98


99
100
101
102
103
104
105
81
82
83
84
85
86
87
88
89
90
91
92

93
94
95
96



97
98
99
100
101
102
103
104
105







+




-
+



-
-
-
+
+







    if not hDst:
        echo(sText, end="")
    else:
        hDst.write(sText)


def loadDictionary (spf):
    "returns the dictionary as a dictionary object"
    if os.path.isfile(spf):
        sJSON = open(spf, "r", encoding="utf-8").read()
        try:
            oJSON = json.loads(sJSON)
        except:
        except json.JSONDecodeError:
            print("# Error. File <" + spf + " is not a valid JSON file.")
            return None
        return oJSON
    else:
        print("# Error: file <" + spf + "> not found.")
        return None
    print("# Error: file <" + spf + "> not found.")
    return None


def main ():
    "launch the CLI (command line interface)"
    xParser = argparse.ArgumentParser()
    xParser.add_argument("-f", "--file", help="parse file (UTF-8 required!) [on Windows, -f is similar to -ff]", type=str)
    xParser.add_argument("-ff", "--file_to_file", help="parse file (UTF-8 required!) and create a result file (*.res.txt)", type=str)
235
236
237
238
239
240
241
242

243
244
245

246
247
248

249
250

251
252
253
254

255
256

257
258
259
260
261
262
263
235
236
237
238
239
240
241

242
243
244

245
246
247

248
249

250
251
252
253

254
255

256
257
258
259
260
261
262
263







-
+


-
+


-
+

-
+



-
+

-
+







                for sRule in sText[3:].strip().split():
                    oGrammarChecker.gce.ignoreRule(sRule)
                echo("done")
            elif sText.startswith("/++ "):
                for sRule in sText[3:].strip().split():
                    oGrammarChecker.gce.reactivateRule(sRule)
                echo("done")
            elif sText == "/debug" or sText == "/d":
            elif sText in ("/debug", "/d"):
                xArgs.debug = not xArgs.debug
                echo("debug mode on"  if xArgs.debug  else "debug mode off")
            elif sText == "/textformatter" or sText == "/tf":
            elif sText in ("/textformatter", "/tf"):
                xArgs.textformatter = not xArgs.textformatter
                echo("textformatter on"  if xArgs.debug  else "textformatter off")
            elif sText == "/help" or sText == "/h":
            elif sText in ("/help", "/h"):
                echo(_HELP)
            elif sText == "/lopt" or sText == "/lo":
            elif sText in ("/lopt", "/lo"):
                oGrammarChecker.gce.displayOptions("fr")
            elif sText.startswith("/lr"):
                sText = sText.strip()
                sFilter = sText[sText.find(" "):].strip()  if sText != "/lr" and sText != "/rules"  else None
                sFilter = sText[sText.find(" "):].strip()  if " " in sText  else None
                oGrammarChecker.gce.displayRules(sFilter)
            elif sText == "/quit" or sText == "/q":
            elif sText in ("/quit", "/q"):
                break
            elif sText.startswith("/rl"):
                # reload (todo)
                pass
            else:
                for sParagraph in txt.getParagraph(sText):
                    if xArgs.textformatter: