Online spell check editor
Qt Widgets
Score 56%
Description:

small adapted QTextEdit class that allows online spell cheking using aspell. For this a highlitghter class and an aspell-class is used.

The code comes in form of an example as i am not aware of how to pack the code for easier reuse.
Last changelog:

9 years ago

Initial functionality.
Code can handle missing aspell as well as language changes in runtime.

b) small error corrected, should now compile under linux

c) Should now work correctly under Linux with utf-8 coding. Furthermore spell correction suggestions are made for the word under the pointer instead of the word under the cursor.
These correctionn seem not to work under Linux. I will take a further look into this soon.

d) corrected error that highlights part of words that contain syntax errors. Thanks to Giuseppe Calá

e) right click now substitues word under pointr

0.2: changed spellchecking engine to hunspell which is integrated. Much faster spell checking !

0.2a: loads and saves user dictionaries automatically. Furthermore a file dialog is used to select the dictionary

0.2b: coorected an error that the context menu did not correct the selected word

tpf80

8 years ago

Thanks, this widget was just was I was looking for as an example of adding spell checking to a QTextEdit.

Report

C

sunderme

9 years ago

hunspell obviously needs a dictionary to work.
The standard assumption is the presence of en_GB.dic in the working path.
If a dictionary is present at different location, this can be set after starting the program in the options.
The complete path to the *.dic file has to be set!

Report

jiveaxe

9 years ago

Hi,
I'm very very happy when found your code since I need it. Since I need Italian spellchecking, your code, like it is, doesn't works good with my language. I apply some modification to the code:

1) I changed line 77 of highlighter.cpp from

QStringList Checkliste = str.split(QRegExp("([^a-z,^A-Z,^\\\\]|(?=\\\\))+"),

to

QStringList Checkliste = str.split(QRegExp("([^\\w,^\\\\]|(?=\\\\))+")

so now accented letters (very common in Italian language) aren't ignored.

2) I changed line 86 of highlighter.cpp from

number = text.count(str);

to

number = text.count(QRegExp("\\b" + str + "\\b"));

and line 91 from

l = text.indexOf(str,l+1);

to

l = text.indexOf(QRegExp("\\b" + str + "\\b"),l+1);

this because if a word is misspelled and this word is a substring of a longer word than this substring is cheched as misspelled while in the new context is right (hoping I was clear...).

3) I have made the object Highlighter *highlighter a member of SpellTextEdit so the new widget SpellTextEdit is simpler to reuse.

Now I have a problem with accented words which are always checked as misspelled even if they are right. I was unable to find the problem, maybe you can, knowing more deeply the code. Probably you have to install aspell-it; here are some accented Italian words:

qualità
maestà
lealtà

Regards

Report

C

sunderme

9 years ago

What system are you using to run "spellcheck" on ?
Is it windows or Linux ? And if Linux, do you know the text coding (utf-8, latin1, etc ?)

Jan

Report

jiveaxe

9 years ago

I use linux (Kubuntu 8.04). I have tryed with the option --encoding=utf-8 in Aspell.cpp but spellchecking doesn't works.

Report

C

sunderme

9 years ago

okay, the problem with the accents arises from encoding.
The code uses .toLatin1(...) in aspell.cpp

This needs to be changed to .toLocal8Bit(...)

I am going to provide new sources hopefully soon, however i have not found out yet why the suggestion of corrected word does not work under Linux.

Report

jiveaxe

9 years ago

Ok, now the spellchecking works right.

Report

C

sunderme

9 years ago

I did not understand yet why you implemented the change number 2.
Could you give an example when the original code fails here ?

Report

jiveaxe

9 years ago

Here is a screen:

http://img134.imageshack.us/my.php?image=imgcht3.jpg

The word "dell" (before the apostrophe) is wrong but the spellchecker marks wrong even 'dell' of the word "della" that is a correct word.

Your code, infact, searches all occurrences of str, even if they are substring of other words; with QRegExp is matched only the whole word.

Report

slux83

9 years ago

Under linux i have opened an utf-8 file and i see some weird characters!

Suggestions doesn't showed

Report

C

sunderme

9 years ago

right now the code is very simple.
Therefore it takes the actual cursor position to determine of which word you want to get spelling suggestions.
To get them, simply place the cursor on the respective word and do a right click ...

Report

subratatamal

9 years ago

I compile the program in vista .When i right click the mouse button.Spell suggestions are not showing up

Report

9 years ago

Initial functionality.
Code can handle missing aspell as well as language changes in runtime.

b) small error corrected, should now compile under linux

c) Should now work correctly under Linux with utf-8 coding. Furthermore spell correction suggestions are made for the word under the pointer instead of the word under the cursor.
These correctionn seem not to work under Linux. I will take a further look into this soon.

d) corrected error that highlights part of words that contain syntax errors. Thanks to Giuseppe Calá

e) right click now substitues word under pointr

0.2: changed spellchecking engine to hunspell which is integrated. Much faster spell checking !

0.2a: loads and saves user dictionaries automatically. Furthermore a file dialog is used to select the dictionary

0.2b: coorected an error that the context menu did not correct the selected word

File (click to download) Version Description Filetype Packagetype License Downloads Date Filesize OCS-Install DL
Details
version
0.2b
updated Dec 14 2008
added Mar 21 2008
downloads today
0
page views today 2