Grammalecte  Check-in [8378730de1]

Overview
Comment:[core] grammar_checker.py: add option <dOptions>
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | core
Files: files | file ages | folders
SHA3-256: 8378730de1a92647851fd83b1ecfd4de750d48af20b5f56172262b8ceff041b0
User & Date: olr on 2018-02-20 13:50:30
Other Links: manifest | tags
Context
2018-02-20
13:51
[server] use gc wrapper check-in: a7e5364e1d user: olr tags: server, trunk
13:50
[core] grammar_checker.py: add option <dOptions> check-in: 8378730de1 user: olr tags: core, trunk
12:12
[core][cli][API] wrapper for the grammar checker check-in: ae76e8614f user: olr tags: cli, core, trunk
Changes

Modified gc_core/py/grammar_checker.py from [ccd29a288b] to [79ce1061e8].

    38     38               self.lxg = importlib.import_module("."+self.sLangCode+".lexicographe", "grammalecte")
    39     39           self.oLexicographer = self.lxg.Lexicographe(self.oSpellChecker)
    40     40           return self.oLexicographer
    41     41   
    42     42       def displayGCOptions (self):
    43     43           self.gce.displayOptions()
    44     44   
    45         -    def getParagraphErrors (self, sText, bContext=False, bSpellSugg=False, bDebug=False):
           45  +    def getParagraphErrors (self, sText, dOptions=None, bContext=False, bSpellSugg=False, bDebug=False):
    46     46           "returns a tuple: (grammar errors, spelling errors)"
    47         -        aGrammErrs = self.gce.parse(sText, "FR", bDebug=bDebug, bContext=bContext)
           47  +        aGrammErrs = self.gce.parse(sText, "FR", bDebug=bDebug, dOptions=dOptions, bContext=bContext)
    48     48           aSpellErrs = self.oSpellChecker.parseParagraph(sText, bSpellSugg)
    49     49           return aGrammErrs, aSpellErrs
    50     50   
    51     51       def generateText (self, sText, bEmptyIfNoErrors=False, bSpellSugg=False, nWidth=100, bDebug=False):
    52     52           pass
    53     53   
    54     54       def generateTextAsJSON (self, sText, bContext=False, bEmptyIfNoErrors=False, bSpellSugg=False, bReturnText=False, bDebug=False):
    55     55           pass
    56     56   
    57         -    def generateParagraph (self, sText, bEmptyIfNoErrors=False, bSpellSugg=False, nWidth=100, bDebug=False):
    58         -        aGrammErrs, aSpellErrs = self.getParagraphErrors(sText, False, bSpellSugg, bDebug)
           57  +    def generateParagraph (self, sText, dOptions=None, bEmptyIfNoErrors=False, bSpellSugg=False, nWidth=100, bDebug=False):
           58  +        aGrammErrs, aSpellErrs = self.getParagraphErrors(sText, dOptions, False, bSpellSugg, bDebug)
    59     59           if bEmptyIfNoErrors and not aGrammErrs and not aSpellErrs:
    60     60               return ""
    61     61           return text.generateParagraph(sText, aGrammErrs, aSpellErrs, nWidth)
    62     62   
    63         -    def generateParagraphAsJSON (self, iIndex, sText, bContext=False, bEmptyIfNoErrors=False, bSpellSugg=False, bReturnText=False, lLineSet=None, bDebug=False):
    64         -        aGrammErrs, aSpellErrs = self.getParagraphErrors(sText, bContext, bSpellSugg, bDebug)
           63  +    def generateParagraphAsJSON (self, iIndex, sText, dOptions=None, bContext=False, bEmptyIfNoErrors=False, bSpellSugg=False, bReturnText=False, lLineSet=None, bDebug=False):
           64  +        aGrammErrs, aSpellErrs = self.getParagraphErrors(sText, dOptions, bContext, bSpellSugg, bDebug)
    65     65           aGrammErrs = list(aGrammErrs)
    66     66           if bEmptyIfNoErrors and not aGrammErrs and not aSpellErrs:
    67     67               return ""
    68     68           if lLineSet:
    69     69               aGrammErrs, aSpellErrs = text.convertToXY(aGrammErrs, aSpellErrs, lLineSet)
    70     70               return json.dumps({ "lGrammarErrors": aGrammErrs, "lSpellingErrors": aSpellErrs }, ensure_ascii=False)
    71     71           if bReturnText:
    72     72               return json.dumps({ "iParagraph": iIndex, "sText": sText, "lGrammarErrors": aGrammErrs, "lSpellingErrors": aSpellErrs }, ensure_ascii=False)
    73     73           return json.dumps({ "iParagraph": iIndex, "lGrammarErrors": aGrammErrs, "lSpellingErrors": aSpellErrs }, ensure_ascii=False)