How to implement Grammar check and spell check using Openoffice

rahul6194

New Member
Hi,

Can anyone assist me how to implement Grammar checking and spell check using Open Office on my clipboard text in background.

Thanks in advance.
 

Cringer

ProgressTalk.com Moderator
Staff member
OpenEdge and OS version would be a start. That being said, I'm not sure how you expect that to work. How would you provide feedback about errors?
 

Cecil

19+ years progress programming and still learning.
Well, there is the MS word solution but I'm not sure how well that works now that Windows has moved over to 64bit.
Progress KB - How to implement a Spell Checker in Progress?

Does it have to be Open Office to do the spell checking?
Is it required for a particular spoken language i.e. English, French, German etc?

Would you consider using a Web Services (REST) to offload the spell checking? There are some paid services or opensource:

Public HTTP Proofreading API - LanguageTool Wiki

Of course, there would be latency in getting a response from the Web Service. But this could be the interim solution.

I'm guessing that this is running on a Windows Desktop.
 

rahul6194

New Member
Hi All,

I have tried to implement this is functionality in MS word application and this is working pretty good. I am passing a sentence and it opens a popup showing spell mistakes in my words/sentence and its correct versions. But I want the same thing to be implemented using the Openoffice.

Check this Out:
Code:
DEFINE VARIABLE chText    AS CHARACTER   NO-UNDO.
DEFINE VARIABLE chrestext AS CHARACTER   NO-UNDO.
DEFINE VARIABLE intHwnd AS INTEGER     NO-UNDO.
DEFINE VARIABLE intResult AS INTEGER     NO-UNDO.

chText = "Testimg my programm".
RUN ipSpellCheck(INPUT chtext,OUTPUT chresText).
MESSAGE chresText
    VIEW-AS ALERT-BOX INFORMATION BUTTONS OK.

PROCEDURE FindWindowA EXTERNAL "USER32.DLL":
DEFINE INPUT PARAMETER intClassName AS LONG.
DEFINE INPUT PARAMETER chrCaption AS CHARACTER.
DEFINE RETURN PARAMETER intHandle AS LONG.
END PROCEDURE.

PROCEDURE BringWindowToTop EXTERNAL "USER32.DLL":
DEFINE INPUT PARAMETER intClassName AS LONG.
DEFINE RETURN PARAMETER intHandle AS LONG.
END PROCEDURE.

PROCEDURE ipSpellCheck:
DEFINE INPUT  PARAMETER ipchText AS CHARACTER   NO-UNDO.
DEFINE OUTPUT PARAMETER opchtext AS CHARACTER   NO-UNDO.

DEFINE VARIABLE wordAppl AS COM-HANDLE NO-UNDO.
DEFINE VARIABLE chDocument AS COM-HANDLE NO-UNDO.

DEFINE VARIABLE cTitle AS CHARACTER   NO-UNDO.

CREATE "Word.Application" wordAppl.
chDocument = wordAppl:Documents:ADD().
wordAppl:Documents:ITEM(1):range(0,0):insertAfter(ipchText).
wordAppl:OPTIONS:CheckGrammarWithSpelling = TRUE.
wordAppl:VISIBLE = TRUE.
cTitle = chDocument:NAME + " - " + wordAppl:NAME.
RUN FindWindowA(0,cTitle,OUTPUT intHwnd).
IF intHwnd <> 0 THEN
RUN BringWindowToTop(INTHwnd, OUTPUT intResult).
wordAppl:VISIBLE = FALSE.

wordAppl:documents:ITEM(1):checkGrammar().
wordAppl:VISIBLE = FALSE.
opchText = wordAppl:documents:ITEM(1):range(0,wordAppl:Documents:ITEM(1):characters:COUNT):TEXT.
wordAppl:QUIT(0).
RELEASE OBJECT wordAppl.
opchText = REPLACE(opchText,CHR(146),CHR(39)).
opchText = REPLACE(opchText,CHR(145),CHR(39)).
opchText = REPLACE(opchText,CHR(147),CHR(34)).
opchText = REPLACE(opchText,CHR(148),CHR(34)).
END PROCEDURE.
Thanks
 
Last edited by a moderator:

Cecil

19+ years progress programming and still learning.
I know this is not what you were looking for but I was curious about doing a web Spell Checker. Unfortunately, it does not fix grammar.

1539859435924.png
 

Attachments

  • 1539858256602.png
    1539858256602.png
    30.9 KB · Views: 3
Last edited:

rahul6194

New Member
Hi Cecil,

Basically I don't want to use MS Office for the spell check utility. I want some Open Source product to this for me like OpenOffice.
So, I am looking for any suggestions how to do this. I know this is not going to check grammar for me.
If possible, could you please share any references how do I go for implementing the web spell checker.

Thanks,
 

Cecil

19+ years progress programming and still learning.
Jimbobnz/ABL-Spell-Checker
Hi Cecil,

Basically, I don't want to use MS Office for the spell check utility. I want some Open Source product to this for me like OpenOffice.
So, I am looking for any suggestions on how to do this. I know this is not going to check grammar for me.
If possible, could you please share any references how do I go for implementing the web spell checker.

Thanks,

I've uploaded the code to GitHub. Note: that I take no responsibility for the use of this code. It is very early in development and should be used for educational / training purposes only, blar, blar, blar, Also, I have no affiliation with languagetool.org. they were just one of the first FREE Web Service providers I came across. Please read Public HTTP Proofreading API - LanguageTool Wiki for use of service.

My Source Code:
Jimbobnz/ABL-Spell-Checker

You might need to import a Root CA cert into your Progress OpenEdge environment to avoid SSL cert errors.
 

Cecil

19+ years progress programming and still learning.
Found a bug with my code that it’s not highlight the text correctly when the is multiple lines .
 
Top