Grammalecte  Check-in [d6ef87ce3a]

Overview
Comment:[lo] note about error positioning
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk | lo
Files: files | file ages | folders
SHA3-256: d6ef87ce3ae9dcf0fefed9abe4c87fc5b94805f65be141b38122b1aa2b32ad05
User & Date: olr on 2021-03-11 15:51:01
Other Links: manifest | tags
Context
2021-03-12
09:54
[fr] ajustements check-in: 4fb93aa07f user: olr tags: trunk, fr
2021-03-11
15:51
[lo] note about error positioning check-in: d6ef87ce3a user: olr tags: trunk, lo
15:41
[fr] ajustements check-in: 98ffeee011 user: olr tags: trunk, fr
Changes

Modified gc_core/py/oxt/Grammalecte.py from [8b3d7a692c] to [0e97a1f7dd].

171
172
173
174
175
176
177
178
179




180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
            sLineType = xChild.getPropertyValue("line_type")
            bMulticolor = bool(xChild.getPropertyValue("line_multicolor"))
            gce.setWriterUnderliningStyle(sLineType, bMulticolor)
        except:
            traceback.print_exc()

    def convertErrorsPosition (self, sText, aErrors):
        "return list of errors with modified position for Writer"
        # last char position of the last error




        nCheckEnd = 0
        for xErr in aErrors:
            nCheckEnd = max(xErr.nErrorStart + xErr.nErrorLength, nCheckEnd)
        # list thresholds of offsets
        lThresholds = []
        for iCursor in range(nCheckEnd):
            nCharVal = ord(sText[iCursor])
            if nCharVal > 65535:    # \U00010000: each chars beyond this point has a length of 2
                lThresholds.append(iCursor + 1)  # +1 because only chars after are shifted
        # modify errors position according to thresholds
        for xErr in aErrors:
            nErrorEnd = xErr.nErrorStart + xErr.nErrorLength
            xErr.nErrorStart += bisect_left(lThresholds, xErr.nErrorStart)
            nErrorEnd += bisect_left(lThresholds, nErrorEnd)
            xErr.nErrorLength = nErrorEnd - xErr.nErrorStart
        return len(lThresholds)







|

>
>
>
>






<
|
|







171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189

190
191
192
193
194
195
196
197
198
            sLineType = xChild.getPropertyValue("line_type")
            bMulticolor = bool(xChild.getPropertyValue("line_multicolor"))
            gce.setWriterUnderliningStyle(sLineType, bMulticolor)
        except:
            traceback.print_exc()

    def convertErrorsPosition (self, sText, aErrors):
        "change position of errors, returns offset"
        # last char position of the last error
        # To see if errors position is correct, try with:
        #   J'en ai mare, 𝐴𝐴𝐴𝐴𝐴, je vient, (𝑉ᵣ = 𝐴·𝑣H). C'est sa, mais oui... Je suis très fâchés.
        #   Qu'il sais, 𝐴𝐴𝐴, je vient, (𝑉ᵣ = 𝐴·𝑣H). Oui... Je suis fâchés

        nCheckEnd = 0
        for xErr in aErrors:
            nCheckEnd = max(xErr.nErrorStart + xErr.nErrorLength, nCheckEnd)
        # list thresholds of offsets
        lThresholds = []
        for iCursor in range(nCheckEnd):

            if ord(sText[iCursor]) > 65535:         # \U00010000: each chars beyond this point has a length of 2
                lThresholds.append(iCursor + 1)     # +1 because only chars after are shifted
        # modify errors position according to thresholds
        for xErr in aErrors:
            nErrorEnd = xErr.nErrorStart + xErr.nErrorLength
            xErr.nErrorStart += bisect_left(lThresholds, xErr.nErrorStart)
            nErrorEnd += bisect_left(lThresholds, nErrorEnd)
            xErr.nErrorLength = nErrorEnd - xErr.nErrorStart
        return len(lThresholds)