Grammalecte  Check-in [2228382a89]

Overview
Comment:[core] fix generateParagraph when empty text
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | core
Files: files | file ages | folders
SHA3-256: 2228382a898afa9e9ec75065c845b46f25ec8e6e50dbb4e4cabaa3345a61837b
User & Date: olr on 2020-03-22 07:51:46
Other Links: manifest | tags
Context
2020-03-22
08:28
[fx] fix Web API for parseText and openPanelForText check-in: 887fd87b74 user: olr tags: fx, trunk
07:51
[core] fix generateParagraph when empty text check-in: 2228382a89 user: olr tags: core, trunk
00:25
[core] fix getParagraphWithErrors when no errors check-in: 9d8c10bf97 user: olr tags: core, trunk
Changes

Modified gc_core/py/text.py from [15f2da6650] to [f92d1e0d16].

54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
            break
    yield sText


def generateParagraph (sParagraph, aGrammErrs, aSpellErrs, nWidth=100):
    "Returns a text with readable errors"
    if not sParagraph:
        return ""
    lGrammErrs = sorted(aGrammErrs, key=lambda d: d["nStart"])
    lSpellErrs = sorted(aSpellErrs, key=lambda d: d['nStart'])
    lErrors = sorted(lGrammErrs + lSpellErrs, key=lambda d: d["nStart"])
    for n, dErr in enumerate(lErrors, 1):
        dErr["iError"] = n
    sText = ""
    nOffset = 0







|







54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
            break
    yield sText


def generateParagraph (sParagraph, aGrammErrs, aSpellErrs, nWidth=100):
    "Returns a text with readable errors"
    if not sParagraph:
        return ("", [])
    lGrammErrs = sorted(aGrammErrs, key=lambda d: d["nStart"])
    lSpellErrs = sorted(aSpellErrs, key=lambda d: d['nStart'])
    lErrors = sorted(lGrammErrs + lSpellErrs, key=lambda d: d["nStart"])
    for n, dErr in enumerate(lErrors, 1):
        dErr["iError"] = n
    sText = ""
    nOffset = 0