|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' |
|
3 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> |
|
4 <html><head> |
|
5 <title>eric4.QScintilla.SpellChecker</title> |
|
6 <style> |
|
7 body { |
|
8 background:white; |
|
9 margin: 0em 1em 10em 1em; |
|
10 color: black; |
|
11 } |
|
12 |
|
13 h1 { color: white; background: #4FA4FF; } |
|
14 h2 { color: white; background: #4FA4FF; } |
|
15 h3 { color: white; background: #00557F; } |
|
16 h4 { color: white; background: #00557F; } |
|
17 |
|
18 a { color: #AA5500; } |
|
19 |
|
20 </style> |
|
21 </head> |
|
22 <body><a NAME="top" ID="top"></a> |
|
23 <h1>eric4.QScintilla.SpellChecker</h1> |
|
24 <p> |
|
25 Module implementing the spell checker for the editor component. |
|
26 </p><p> |
|
27 The spell checker is based on pyenchant. |
|
28 </p> |
|
29 <h3>Global Attributes</h3> |
|
30 <table> |
|
31 <tr><td>None</td></tr> |
|
32 </table> |
|
33 <h3>Classes</h3> |
|
34 <table> |
|
35 <tr> |
|
36 <td><a href="#SpellChecker">SpellChecker</a></td> |
|
37 <td>Class implementing a pyenchant based spell checker.</td> |
|
38 </tr> |
|
39 </table> |
|
40 <h3>Functions</h3> |
|
41 <table> |
|
42 <tr><td>None</td></tr> |
|
43 </table> |
|
44 <hr /><hr /> |
|
45 <a NAME="SpellChecker" ID="SpellChecker"></a> |
|
46 <h2>SpellChecker</h2> |
|
47 <p> |
|
48 Class implementing a pyenchant based spell checker. |
|
49 </p> |
|
50 <h3>Derived from</h3> |
|
51 QObject |
|
52 <h3>Class Attributes</h3> |
|
53 <table> |
|
54 <tr><td>_spelling_dict</td></tr><tr><td>_spelling_lang</td></tr> |
|
55 </table> |
|
56 <h3>Methods</h3> |
|
57 <table> |
|
58 <tr> |
|
59 <td><a href="#SpellChecker.__init__">SpellChecker</a></td> |
|
60 <td>Constructor</td> |
|
61 </tr><tr> |
|
62 <td><a href="#SpellChecker.__checkDocumentPart">__checkDocumentPart</a></td> |
|
63 <td>Private method to check some part of the document.</td> |
|
64 </tr><tr> |
|
65 <td><a href="#SpellChecker.__getNextWord">__getNextWord</a></td> |
|
66 <td>Private method to get the next word in the text after the given position.</td> |
|
67 </tr><tr> |
|
68 <td><a href="#SpellChecker.__incrementalCheck">__incrementalCheck</a></td> |
|
69 <td>Private method to check the document incrementally.</td> |
|
70 </tr><tr> |
|
71 <td><a href="#SpellChecker.__iter__">__iter__</a></td> |
|
72 <td>Private method to create an iterator.</td> |
|
73 </tr><tr> |
|
74 <td><a href="#SpellChecker.__next__">__next__</a></td> |
|
75 <td>Private method to advance to the next error.</td> |
|
76 </tr><tr> |
|
77 <td><a href="#SpellChecker._getDict">_getDict</a></td> |
|
78 <td>Protected classmethod to get a new dictionary.</td> |
|
79 </tr><tr> |
|
80 <td><a href="#SpellChecker.add">add</a></td> |
|
81 <td>Public method to add a word to the personal word list.</td> |
|
82 </tr><tr> |
|
83 <td><a href="#SpellChecker.checkCurrentPage">checkCurrentPage</a></td> |
|
84 <td>Private method to check the currently visible page.</td> |
|
85 </tr><tr> |
|
86 <td><a href="#SpellChecker.checkDocument">checkDocument</a></td> |
|
87 <td>Public method to check the complete document</td> |
|
88 </tr><tr> |
|
89 <td><a href="#SpellChecker.checkDocumentIncrementally">checkDocumentIncrementally</a></td> |
|
90 <td>Public method to check the document incrementally.</td> |
|
91 </tr><tr> |
|
92 <td><a href="#SpellChecker.checkLines">checkLines</a></td> |
|
93 <td>Public method to check some lines of text.</td> |
|
94 </tr><tr> |
|
95 <td><a href="#SpellChecker.checkSelection">checkSelection</a></td> |
|
96 <td>Private method to check the current selection.</td> |
|
97 </tr><tr> |
|
98 <td><a href="#SpellChecker.checkWord">checkWord</a></td> |
|
99 <td>Public method to check the word at position pos.</td> |
|
100 </tr><tr> |
|
101 <td><a href="#SpellChecker.clearAll">clearAll</a></td> |
|
102 <td>Public method to clear all spelling markers.</td> |
|
103 </tr><tr> |
|
104 <td><a href="#SpellChecker.getAvailableLanguages">getAvailableLanguages</a></td> |
|
105 <td>Public classmethod to get all available languages.</td> |
|
106 </tr><tr> |
|
107 <td><a href="#SpellChecker.getContext">getContext</a></td> |
|
108 <td>Public method to get the context of a faulty word.</td> |
|
109 </tr><tr> |
|
110 <td><a href="#SpellChecker.getError">getError</a></td> |
|
111 <td>Public method to get information about the last error found.</td> |
|
112 </tr><tr> |
|
113 <td><a href="#SpellChecker.getLanguage">getLanguage</a></td> |
|
114 <td>Public method to get the current language.</td> |
|
115 </tr><tr> |
|
116 <td><a href="#SpellChecker.getSuggestions">getSuggestions</a></td> |
|
117 <td>Public method to get suggestions for the given word.</td> |
|
118 </tr><tr> |
|
119 <td><a href="#SpellChecker.ignoreAlways">ignoreAlways</a></td> |
|
120 <td>Public method to tell the checker, to always ignore the given word or the current word.</td> |
|
121 </tr><tr> |
|
122 <td><a href="#SpellChecker.initCheck">initCheck</a></td> |
|
123 <td>Public method to initialize a spell check.</td> |
|
124 </tr><tr> |
|
125 <td><a href="#SpellChecker.isAvailable">isAvailable</a></td> |
|
126 <td>Public classmethod to check, if spellchecking is available.</td> |
|
127 </tr><tr> |
|
128 <td><a href="#SpellChecker.next">next</a></td> |
|
129 <td>Public method to advance to the next error.</td> |
|
130 </tr><tr> |
|
131 <td><a href="#SpellChecker.remove">remove</a></td> |
|
132 <td>Public method to add a word to the personal exclude list.</td> |
|
133 </tr><tr> |
|
134 <td><a href="#SpellChecker.replace">replace</a></td> |
|
135 <td>Public method to tell the checker to replace the current word with the replacement string.</td> |
|
136 </tr><tr> |
|
137 <td><a href="#SpellChecker.replaceAlways">replaceAlways</a></td> |
|
138 <td>Public method to tell the checker to always replace the current word with the replacement string.</td> |
|
139 </tr><tr> |
|
140 <td><a href="#SpellChecker.setDefaultLanguage">setDefaultLanguage</a></td> |
|
141 <td>Public classmethod to set the default language.</td> |
|
142 </tr><tr> |
|
143 <td><a href="#SpellChecker.setLanguage">setLanguage</a></td> |
|
144 <td>Public method to set the current language.</td> |
|
145 </tr><tr> |
|
146 <td><a href="#SpellChecker.setMinimumWordSize">setMinimumWordSize</a></td> |
|
147 <td>Public method to set the minimum word size.</td> |
|
148 </tr><tr> |
|
149 <td><a href="#SpellChecker.stopIncrementalCheck">stopIncrementalCheck</a></td> |
|
150 <td>Public method to stop an incremental check.</td> |
|
151 </tr> |
|
152 </table> |
|
153 <a NAME="SpellChecker.__init__" ID="SpellChecker.__init__"></a> |
|
154 <h4>SpellChecker (Constructor)</h4> |
|
155 <b>SpellChecker</b>(<i>editor, indicator, defaultLanguage = None, checkRegion = None</i>) |
|
156 <p> |
|
157 Constructor |
|
158 </p><dl> |
|
159 <dt><i>editor</i></dt> |
|
160 <dd> |
|
161 reference to the editor object (QScintilla.Editor) |
|
162 </dd><dt><i>indicator</i></dt> |
|
163 <dd> |
|
164 spell checking indicator |
|
165 </dd><dt><i>defaultLanguage=</i></dt> |
|
166 <dd> |
|
167 the language to be used as the default (string). |
|
168 The string should be in language locale format (e.g. en_US, de). |
|
169 </dd><dt><i>checkRegion=</i></dt> |
|
170 <dd> |
|
171 reference to a function to check for a valid region |
|
172 </dd> |
|
173 </dl><a NAME="SpellChecker.__checkDocumentPart" ID="SpellChecker.__checkDocumentPart"></a> |
|
174 <h4>SpellChecker.__checkDocumentPart</h4> |
|
175 <b>__checkDocumentPart</b>(<i>startPos, endPos</i>) |
|
176 <p> |
|
177 Private method to check some part of the document. |
|
178 </p><dl> |
|
179 <dt><i>startPos</i></dt> |
|
180 <dd> |
|
181 position to start at (integer) |
|
182 </dd><dt><i>endPos</i></dt> |
|
183 <dd> |
|
184 position to end at (integer) |
|
185 </dd> |
|
186 </dl><a NAME="SpellChecker.__getNextWord" ID="SpellChecker.__getNextWord"></a> |
|
187 <h4>SpellChecker.__getNextWord</h4> |
|
188 <b>__getNextWord</b>(<i>pos, endPosition</i>) |
|
189 <p> |
|
190 Private method to get the next word in the text after the given position. |
|
191 </p><dl> |
|
192 <dt><i>pos</i></dt> |
|
193 <dd> |
|
194 position to start word extraction (integer) |
|
195 </dd><dt><i>endPosition</i></dt> |
|
196 <dd> |
|
197 position to stop word extraction (integer) |
|
198 </dd> |
|
199 </dl><dl> |
|
200 <dt>Returns:</dt> |
|
201 <dd> |
|
202 tuple of three values (the extracted word (string), |
|
203 start position (integer), end position (integer)) |
|
204 </dd> |
|
205 </dl><a NAME="SpellChecker.__incrementalCheck" ID="SpellChecker.__incrementalCheck"></a> |
|
206 <h4>SpellChecker.__incrementalCheck</h4> |
|
207 <b>__incrementalCheck</b>(<i></i>) |
|
208 <p> |
|
209 Private method to check the document incrementally. |
|
210 </p><a NAME="SpellChecker.__iter__" ID="SpellChecker.__iter__"></a> |
|
211 <h4>SpellChecker.__iter__</h4> |
|
212 <b>__iter__</b>(<i></i>) |
|
213 <p> |
|
214 Private method to create an iterator. |
|
215 </p><a NAME="SpellChecker.__next__" ID="SpellChecker.__next__"></a> |
|
216 <h4>SpellChecker.__next__</h4> |
|
217 <b>__next__</b>(<i></i>) |
|
218 <p> |
|
219 Private method to advance to the next error. |
|
220 </p><a NAME="SpellChecker._getDict" ID="SpellChecker._getDict"></a> |
|
221 <h4>SpellChecker._getDict</h4> |
|
222 <b>_getDict</b>(<i>lang, pwl = "", pel = ""</i>) |
|
223 <p> |
|
224 Protected classmethod to get a new dictionary. |
|
225 </p><dl> |
|
226 <dt><i>lang</i></dt> |
|
227 <dd> |
|
228 the language to be used as the default (string). |
|
229 The string should be in language locale format (e.g. en_US, de). |
|
230 </dd><dt><i>pwl=</i></dt> |
|
231 <dd> |
|
232 name of the personal/project word list (string) |
|
233 </dd><dt><i>pel=</i></dt> |
|
234 <dd> |
|
235 name of the personal/project exclude list (string) |
|
236 </dd> |
|
237 </dl><dl> |
|
238 <dt>Returns:</dt> |
|
239 <dd> |
|
240 reference to the dictionary (enchant.Dict) |
|
241 </dd> |
|
242 </dl><a NAME="SpellChecker.add" ID="SpellChecker.add"></a> |
|
243 <h4>SpellChecker.add</h4> |
|
244 <b>add</b>(<i>word = None</i>) |
|
245 <p> |
|
246 Public method to add a word to the personal word list. |
|
247 </p><dl> |
|
248 <dt><i>word</i></dt> |
|
249 <dd> |
|
250 word to add (string) |
|
251 </dd> |
|
252 </dl><a NAME="SpellChecker.checkCurrentPage" ID="SpellChecker.checkCurrentPage"></a> |
|
253 <h4>SpellChecker.checkCurrentPage</h4> |
|
254 <b>checkCurrentPage</b>(<i></i>) |
|
255 <p> |
|
256 Private method to check the currently visible page. |
|
257 </p><a NAME="SpellChecker.checkDocument" ID="SpellChecker.checkDocument"></a> |
|
258 <h4>SpellChecker.checkDocument</h4> |
|
259 <b>checkDocument</b>(<i></i>) |
|
260 <p> |
|
261 Public method to check the complete document |
|
262 </p><a NAME="SpellChecker.checkDocumentIncrementally" ID="SpellChecker.checkDocumentIncrementally"></a> |
|
263 <h4>SpellChecker.checkDocumentIncrementally</h4> |
|
264 <b>checkDocumentIncrementally</b>(<i></i>) |
|
265 <p> |
|
266 Public method to check the document incrementally. |
|
267 </p><a NAME="SpellChecker.checkLines" ID="SpellChecker.checkLines"></a> |
|
268 <h4>SpellChecker.checkLines</h4> |
|
269 <b>checkLines</b>(<i>firstLine, lastLine</i>) |
|
270 <p> |
|
271 Public method to check some lines of text. |
|
272 </p><dl> |
|
273 <dt><i>firstLine</i></dt> |
|
274 <dd> |
|
275 line number of first line to check (integer) |
|
276 </dd><dt><i>lastLine</i></dt> |
|
277 <dd> |
|
278 line number of last line to check (integer) |
|
279 </dd> |
|
280 </dl><a NAME="SpellChecker.checkSelection" ID="SpellChecker.checkSelection"></a> |
|
281 <h4>SpellChecker.checkSelection</h4> |
|
282 <b>checkSelection</b>(<i></i>) |
|
283 <p> |
|
284 Private method to check the current selection. |
|
285 </p><a NAME="SpellChecker.checkWord" ID="SpellChecker.checkWord"></a> |
|
286 <h4>SpellChecker.checkWord</h4> |
|
287 <b>checkWord</b>(<i>pos, atEnd = False</i>) |
|
288 <p> |
|
289 Public method to check the word at position pos. |
|
290 </p><dl> |
|
291 <dt><i>pos</i></dt> |
|
292 <dd> |
|
293 position to check at (integer) |
|
294 </dd><dt><i>atEnd=</i></dt> |
|
295 <dd> |
|
296 flag indicating the position is at the end of the word |
|
297 to check (boolean) |
|
298 </dd> |
|
299 </dl><a NAME="SpellChecker.clearAll" ID="SpellChecker.clearAll"></a> |
|
300 <h4>SpellChecker.clearAll</h4> |
|
301 <b>clearAll</b>(<i></i>) |
|
302 <p> |
|
303 Public method to clear all spelling markers. |
|
304 </p><a NAME="SpellChecker.getAvailableLanguages" ID="SpellChecker.getAvailableLanguages"></a> |
|
305 <h4>SpellChecker.getAvailableLanguages</h4> |
|
306 <b>getAvailableLanguages</b>(<i></i>) |
|
307 <p> |
|
308 Public classmethod to get all available languages. |
|
309 </p><dl> |
|
310 <dt>Returns:</dt> |
|
311 <dd> |
|
312 list of available languages (list of strings) |
|
313 </dd> |
|
314 </dl><a NAME="SpellChecker.getContext" ID="SpellChecker.getContext"></a> |
|
315 <h4>SpellChecker.getContext</h4> |
|
316 <b>getContext</b>(<i>wordStart, wordEnd</i>) |
|
317 <p> |
|
318 Public method to get the context of a faulty word. |
|
319 </p><dl> |
|
320 <dt><i>wordStart</i></dt> |
|
321 <dd> |
|
322 the starting position of the word (integer) |
|
323 </dd><dt><i>wordEnd</i></dt> |
|
324 <dd> |
|
325 the ending position of the word (integer) |
|
326 </dd> |
|
327 </dl><dl> |
|
328 <dt>Returns:</dt> |
|
329 <dd> |
|
330 tuple of the leading and trailing context (string, string) |
|
331 </dd> |
|
332 </dl><a NAME="SpellChecker.getError" ID="SpellChecker.getError"></a> |
|
333 <h4>SpellChecker.getError</h4> |
|
334 <b>getError</b>(<i></i>) |
|
335 <p> |
|
336 Public method to get information about the last error found. |
|
337 </p><dl> |
|
338 <dt>Returns:</dt> |
|
339 <dd> |
|
340 tuple of last faulty word (string), starting position of the |
|
341 faulty word (integer) and ending position of the faulty word (integer) |
|
342 </dd> |
|
343 </dl><a NAME="SpellChecker.getLanguage" ID="SpellChecker.getLanguage"></a> |
|
344 <h4>SpellChecker.getLanguage</h4> |
|
345 <b>getLanguage</b>(<i></i>) |
|
346 <p> |
|
347 Public method to get the current language. |
|
348 </p><dl> |
|
349 <dt>Returns:</dt> |
|
350 <dd> |
|
351 current language in language locale format (string) |
|
352 </dd> |
|
353 </dl><a NAME="SpellChecker.getSuggestions" ID="SpellChecker.getSuggestions"></a> |
|
354 <h4>SpellChecker.getSuggestions</h4> |
|
355 <b>getSuggestions</b>(<i>word</i>) |
|
356 <p> |
|
357 Public method to get suggestions for the given word. |
|
358 </p><dl> |
|
359 <dt><i>word</i></dt> |
|
360 <dd> |
|
361 word to get suggestions for (string) |
|
362 </dd> |
|
363 </dl><dl> |
|
364 <dt>Returns:</dt> |
|
365 <dd> |
|
366 list of suggestions (list of strings) |
|
367 </dd> |
|
368 </dl><a NAME="SpellChecker.ignoreAlways" ID="SpellChecker.ignoreAlways"></a> |
|
369 <h4>SpellChecker.ignoreAlways</h4> |
|
370 <b>ignoreAlways</b>(<i>word = None</i>) |
|
371 <p> |
|
372 Public method to tell the checker, to always ignore the given word |
|
373 or the current word. |
|
374 </p><dl> |
|
375 <dt><i>word</i></dt> |
|
376 <dd> |
|
377 word to be ignored (string) |
|
378 </dd> |
|
379 </dl><a NAME="SpellChecker.initCheck" ID="SpellChecker.initCheck"></a> |
|
380 <h4>SpellChecker.initCheck</h4> |
|
381 <b>initCheck</b>(<i>startPos, endPos</i>) |
|
382 <p> |
|
383 Public method to initialize a spell check. |
|
384 </p><dl> |
|
385 <dt><i>startPos</i></dt> |
|
386 <dd> |
|
387 position to start at (integer) |
|
388 </dd><dt><i>endPos</i></dt> |
|
389 <dd> |
|
390 position to end at (integer) |
|
391 </dd> |
|
392 </dl><dl> |
|
393 <dt>Returns:</dt> |
|
394 <dd> |
|
395 flag indicating successful initialization (boolean) |
|
396 </dd> |
|
397 </dl><a NAME="SpellChecker.isAvailable" ID="SpellChecker.isAvailable"></a> |
|
398 <h4>SpellChecker.isAvailable</h4> |
|
399 <b>isAvailable</b>(<i></i>) |
|
400 <p> |
|
401 Public classmethod to check, if spellchecking is available. |
|
402 </p><dl> |
|
403 <dt>Returns:</dt> |
|
404 <dd> |
|
405 flag indicating availability (boolean) |
|
406 </dd> |
|
407 </dl><a NAME="SpellChecker.next" ID="SpellChecker.next"></a> |
|
408 <h4>SpellChecker.next</h4> |
|
409 <b>next</b>(<i></i>) |
|
410 <p> |
|
411 Public method to advance to the next error. |
|
412 </p><dl> |
|
413 <dt>Returns:</dt> |
|
414 <dd> |
|
415 self |
|
416 </dd> |
|
417 </dl><a NAME="SpellChecker.remove" ID="SpellChecker.remove"></a> |
|
418 <h4>SpellChecker.remove</h4> |
|
419 <b>remove</b>(<i>word</i>) |
|
420 <p> |
|
421 Public method to add a word to the personal exclude list. |
|
422 </p><dl> |
|
423 <dt><i>word</i></dt> |
|
424 <dd> |
|
425 word to add (string) |
|
426 </dd> |
|
427 </dl><a NAME="SpellChecker.replace" ID="SpellChecker.replace"></a> |
|
428 <h4>SpellChecker.replace</h4> |
|
429 <b>replace</b>(<i>replacement</i>) |
|
430 <p> |
|
431 Public method to tell the checker to replace the current word with |
|
432 the replacement string. |
|
433 </p><dl> |
|
434 <dt><i>replacement</i></dt> |
|
435 <dd> |
|
436 replacement string (string) |
|
437 </dd> |
|
438 </dl><a NAME="SpellChecker.replaceAlways" ID="SpellChecker.replaceAlways"></a> |
|
439 <h4>SpellChecker.replaceAlways</h4> |
|
440 <b>replaceAlways</b>(<i>replacement</i>) |
|
441 <p> |
|
442 Public method to tell the checker to always replace the current word |
|
443 with the replacement string. |
|
444 </p><dl> |
|
445 <dt><i>replacement</i></dt> |
|
446 <dd> |
|
447 replacement string (string) |
|
448 </dd> |
|
449 </dl><a NAME="SpellChecker.setDefaultLanguage" ID="SpellChecker.setDefaultLanguage"></a> |
|
450 <h4>SpellChecker.setDefaultLanguage</h4> |
|
451 <b>setDefaultLanguage</b>(<i>language</i>) |
|
452 <p> |
|
453 Public classmethod to set the default language. |
|
454 </p><dl> |
|
455 <dt><i>language</i></dt> |
|
456 <dd> |
|
457 the language to be used as the default (string). |
|
458 The string should be in language locale format (e.g. en_US, de). |
|
459 </dd> |
|
460 </dl><a NAME="SpellChecker.setLanguage" ID="SpellChecker.setLanguage"></a> |
|
461 <h4>SpellChecker.setLanguage</h4> |
|
462 <b>setLanguage</b>(<i>language, pwl = "", pel = ""</i>) |
|
463 <p> |
|
464 Public method to set the current language. |
|
465 </p><dl> |
|
466 <dt><i>language</i></dt> |
|
467 <dd> |
|
468 the language to be used as the default (string). |
|
469 The string should be in language locale format (e.g. en_US, de). |
|
470 </dd><dt><i>pwl=</i></dt> |
|
471 <dd> |
|
472 name of the personal/project word list (string) |
|
473 </dd><dt><i>pel=</i></dt> |
|
474 <dd> |
|
475 name of the personal/project exclude list (string) |
|
476 </dd> |
|
477 </dl><a NAME="SpellChecker.setMinimumWordSize" ID="SpellChecker.setMinimumWordSize"></a> |
|
478 <h4>SpellChecker.setMinimumWordSize</h4> |
|
479 <b>setMinimumWordSize</b>(<i>size</i>) |
|
480 <p> |
|
481 Public method to set the minimum word size. |
|
482 </p><dl> |
|
483 <dt><i>size</i></dt> |
|
484 <dd> |
|
485 minimum word size (integer) |
|
486 </dd> |
|
487 </dl><a NAME="SpellChecker.stopIncrementalCheck" ID="SpellChecker.stopIncrementalCheck"></a> |
|
488 <h4>SpellChecker.stopIncrementalCheck</h4> |
|
489 <b>stopIncrementalCheck</b>(<i></i>) |
|
490 <p> |
|
491 Public method to stop an incremental check. |
|
492 </p> |
|
493 <div align="right"><a href="#top">Up</a></div> |
|
494 <hr /> |
|
495 </body></html> |