eric6/Documentation/Source/eric6.QScintilla.SpellChecker.html

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

eric ide

mercurial