
Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net
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.
12 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
12 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
12 years ago
Report
sunderme
12 years ago
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
12 years ago
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
sunderme
12 years ago
Could you give an example when the original code fails here ?
Report
jiveaxe
12 years ago
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
sunderme
12 years ago
Is it windows or Linux ? And if Linux, do you know the text coding (utf-8, latin1, etc ?)
Jan
Report
jiveaxe
12 years ago
Report
sunderme
12 years ago
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
12 years ago
Report
slux83
12 years ago
Suggestions doesn't showed
Report
sunderme
12 years ago
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
12 years ago
Report