[Bug 159652] Finding a way to join a suffix to the word immediately before it, using autocorrect function

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Tue Feb 13 12:56:13 UTC 2024


https://bugs.documentfoundation.org/show_bug.cgi?id=159652

László Németh <nemeth at numbertext.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WORKSFORME
             Status|NEW                         |RESOLVED

--- Comment #5 from László Németh <nemeth at numbertext.org> ---
A possible solution is to use a non-space separator, e.g. comma, and the .*
pattern to recognize the suffix in the end of the character sequence:

mogl -> mógł
.*,bys -> byś

After typing the comma, mogl changed to mógł. After following with ,bys:

mogl,bys -> mógłbyś


The other solution to use Hunspell spell checker to add the missing diacritics,
accepting the their suggestions automatically. It seems, the dictionary
contains all the Polish diacritics, so it can suggest the right alternatives
with diacritics:

== pl_PL.aff ==
MAP 8
MAP aą
MAP cć
MAP eę
MAP lł
MAP nń
MAP oóu
MAP sś
MAP zżź

So with a LibreBasic or pyUNO macro, it's possible to add the missing
diacritics automatically (except when the result is ambiguous), e.g. by
clicking on a button at the end of the document editing. As a code snippet, see
for example the following LibreBasic code snippet from
https://forum.openoffice.org/en/forum/viewtopic.php?t=1222, using XSpellChecker
service of LibreOffice UNO API via
com.sun.star.linguistic2.LinguServiceManager:

Sub WrongWordsList 

    Dim oDocModel as Variant 
    Dim oTextCursor as Variant 
    Dim oLinguSvcMgr as Variant 
    Dim oSpellChk as Variant 
    Dim oListDocFrame as Variant 
    Dim oListDocModel as Variant 
    Dim sListaPalabras as String 
    Dim aProp() As New com.sun.star.beans.PropertyValue 

    oDocModel = StarDesktop.CurrentFrame.Controller.getModel() 
    If IsNull(oDocModel) Then 
        MsgBox("There's no active document." + Chr(13)) 
        Exit Sub 
    End If 

    If Not HasUnoInterfaces (oDocModel, "com.sun.star.text.XTextDocument") Then 
        MsgBox("This document doesn't support the 'XTextDocument' interface." +
Chr(13)) 
        Exit Sub 
    End If 

    oTextCursor = oDocModel.Text.createTextCursor() 
    oTextCursor.gotoStart(False) 

    oLinguSvcMgr =
createUnoService("com.sun.star.linguistic2.LinguServiceManager") 
    If Not IsNull(oLinguSvcMgr) Then 
        oSpellChk = oLinguSvcMgr.getSpellChecker() 
    End If 
    If IsNull (oSpellChk) Then 
        MsgBox("It's not possible to access to the spellcheck." + Chr(13)) 
        Exit Sub 
    End If 

    Do 
        If oTextCursor.isStartOfWord() Then 
            oTextCursor.gotoEndOfWord(True) 
            ' Verificar si la palabra está bien escrita 
            If Not isEmpty (oTextCursor.getPropertyValue("CharLocale")) Then 
                    If Not oSpellChk.isValid(oTextCursor.getString(),
oTextCursor.getPropertyValue("CharLocale"), aProp()) Then 
               sListaPalabras = sListaPalabras + oTextCursor.getString() +
Chr(13) 
           End If 
        End If 
            oTextCursor.collapseToEnd() 
        End If 
    Loop While oTextCursor.gotoNextWord(False) 

    If Len(sListaPalabras) = 0 Then 
        MsgBox("There are no errors in the document.") 
        Exit Sub 
    End If 

    oListDocFrame = StarDesktop.findFrame("fListarPalabrasIncorrectas",
com.sun.star.frame.FrameSearchFlag.ALL) 
    If IsNull(oListDocFrame) Then 
        oListDocModel =
StarDesktop.loadComponentFromURL("private:factory/swriter",
"fListarPalabrasIncorrectas", com.sun.star.frame.FrameSearchFlag.CREATE,
aProp()) 
        oListDocFrame = oListDocModel.CurrentController.getFrame() 
    Else 
        oListDocModel = oListDocFrame.Controller.getModel() 
    End If 

    oTextCursor = oListDocModel.Text.createTextCursor() 
    oTextCursor.gotoEnd(False) 

    oListDocModel.Text.insertString (oTextCursor, sListaPalabras, False) 

    oListDocFrame.activate() 

End Sub


And the other code snippet to modify the wrong words (but also fixing a problem
in XSpellChecker usage that has since been solved):

https://forum.openoffice.org/en/forum/viewtopic.php?p=425651

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Libreoffice-ux-advise mailing list