src/eric7/Documentation/Source/eric7.QScintilla.SpellChecker.html

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

eric ide

mercurial