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