Index: grammalecte-cli.py ================================================================== --- grammalecte-cli.py +++ grammalecte-cli.py @@ -49,11 +49,13 @@ aGrammErrs = gce.parse(sText, "FR", bDebug=bDebug, bContext=bContext) aSpellErrs = [] for dToken in oTokenizer.genTokens(sText): if dToken['sType'] == "WORD" and not oSpellChecker.isValidToken(dToken['sValue']): if bSpellSugg: - dToken['aSuggestions'] = oSpellChecker.suggest(dToken['sValue']) + dToken['aSuggestions'] = [] + for lSugg in oSpellChecker.suggest(dToken['sValue']): + dToken['aSuggestions'].extend(lSugg) aSpellErrs.append(dToken) return aGrammErrs, aSpellErrs def generateText (sText, oTokenizer, oSpellChecker, bDebug=False, bEmptyIfNoErrors=False, bSpellSugg=False, nWidth=100): @@ -142,16 +144,16 @@ if xArgs.list_rules: gce.displayRules(None if xArgs.list_rules == "*" else xArgs.list_rules) exit() if xArgs.suggest: - lSugg = oSpellChecker.suggest(xArgs.suggest) - if xArgs.json: - sText = json.dumps({ "aSuggestions": lSugg }, ensure_ascii=False) - else: - sText = "Suggestions : " + " | ".join(lSugg) - echo(sText) + for lSugg in oSpellChecker.suggest(xArgs.suggest): + if xArgs.json: + sText = json.dumps({ "aSuggestions": lSugg }, ensure_ascii=False) + else: + sText = "Suggestions : " + " | ".join(lSugg) + echo(sText) exit() if not xArgs.json: xArgs.context = False @@ -220,12 +222,12 @@ for sMorph in oSpellChecker.getMorph(sWord): echo(" {:<32} {}".format(sMorph, oLexGraphe.formatTags(sMorph))) elif sText.startswith("!"): for sWord in sText[1:].strip().split(): if sWord: - echo(" | ".join(oSpellChecker.suggest(sWord))) - #echo(" | ".join(oSpellChecker.suggest2(sWord))) + for lSugg in oSpellChecker.suggest(sWord): + echo(" | ".join(lSugg)) elif sText.startswith(">"): oSpellChecker.drawPath(sText[1:].strip()) elif sText.startswith("="): for sRes in oSpellChecker.select(sText[1:].strip()): echo(sRes)